Is there any way to stop an Interpolate once it has started?

I have an actor with drag that I apply velocity to. When the velocity gets below a threshold, I have the actor interpolate its position to a specific point.

I then apply a velocity to the actor, but it doesn't seem to take effect until after the actor has finished interpolating. I've tried having the interpolate behavior in various rules, but to no avail.

Is there any way to override the interpolate?

Sorry if this is confusing, I would be more than happy to clarify.

Best Answer

Answers

  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    Thanks for the response. I expected that was the case after some testing, but I was hoping I was wrong.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited December 2012

    @ShmirlyWhirl

    Hi, A small point to mention: velocity is "made" if you're interpolating an actor's position over time; in other words, when its moving, it has a velocity, so if you add a velocity change if your interpolating an actor's position, it won't kick in until the interpolation has finished...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    @gyroscope

    I get what your saying, but this is what I found playing around with it.

    I set up a scene to play around with it. I had a test actor interpolate its position. I can change its velocity while it's interpolating, but that does not affect the actors motion until it has finished interpolating.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited December 2012

    Yes, sure, it's because in that case by interpolating an actor's distance over a time creates a velocity value, and this will take precedence over any other velocity attribute.

    But for interest, if you wanted something else to be happening to your actor during an interpolation involving velocity, then providing it's not to do with velocity, it'll be OK.

    An example:

    Timer: After 2 seconds
    Change attribute self.Color.Alpha to .4
    --
    Interpolate self.Position.X to 480
    Duration 4 seconds

    And two interpolates will work together too...so just not those moving with added change of speed...

    Hope this is of some sort of help... (although doesn't answer your question regarding stopping an interpolate)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    This why I wished moved to worked right and then we could use the additive and stacked parts of those behaviors. I've always wanted to know more about those functions maybe I should depart to my lab and do some testing. Egor, fire up Gamesalad and get me coffee!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • RacetotheMoonRacetotheMoon Member Posts: 323
    edited December 2012
    I remember having this same problem.. and if I remember correctly.

    Try making your interpolation duration a variable. Then, when your event happens, set that variable to zero. The interpolation should stop and you'll be free to do with that object as you please.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @RacetotheMoon Hi, that would be great, but unfortunately, changing the duration to zero, it'll stop the interpolation OK, but the actor will then jump to its final set destination.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • RacetotheMoonRacetotheMoon Member Posts: 323
    @gyroscope Well.. I don't remember having that problem. Perhaps I also had the location as a variable, it's been too long and I'm not in a postion to open my project to see how I did it. I do know there's a way around it, however..
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited December 2012

    @tenrdrmer Looks interesting approach, Aaron; it'll be interesting to see if your solution is similar to mine. :-) I'll check it out now.
    @gyroscope Well.. I don't remember having that problem. Perhaps I also had the location as a variable, it's been too long and I'm not in a postion to open my project to see how I did it. I do know there's a way around it, however..
    @RaceToTheMoon Yes, you're right, there's more to it than just the duration set as an attribute... the destination as an attribute too, as you say, and a constrain needed, as I discovered. :-)

    @ShmirlyWhirl Anyhow, this was intriguing me so I did a little test, (before I looked at the files from @tenrdrmer ) and made game file to stop an interpolate with a mouse click; hopefully it can be modified for your use.

    Edit: excellent solutions from @tenrdrmer and although mine's is a bit different; all might be useful in different situations, hopefully.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    the demos I posted up for download are the project files to the old arcade links from that old thread
  • PixelMetalPixelMetal Member Posts: 283
    I have an actor with drag that I apply velocity to. When the velocity gets below a threshold, I have the actor interpolate its position to a specific point.

    I then apply a velocity to the actor, but it doesn't seem to take effect until after the actor has finished interpolating. I've tried having the interpolate behavior in various rules, but to no avail.

    Is there any way to override the interpolate?

    Sorry if this is confusing, I would be more than happy to clarify.
    You could set a new interpolate to the current location of the object. Have it read in the attributes you want to stop moving with interpolate from a game or actor-level attribute. This works perfectly in my current project.
  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    edited December 2012
    Thank you everyone for your input. It occurs to me I did not explain my problem too well.

    However, thanks to @gyroscope and @RacetotheMoon, I was able to get the result I wanted by having the duration be a variable and changing it to zero.

    Thanks guys, I would have never thought to try that.

    EDIT:
    I take that back, occasionally it still snaps to the end position. I'll play around with it, see what I can come up with.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited December 2012

    EDIT:
    I take that back, occasionally it still snaps to the end position. I'll play around with it, see what I can come up with.
    Hi, possibly you've made the constrained attribute, the one that goes into the "To:" in the Interpolate, as an integer, when it should be a real?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    How did I miss this thread?! Clever solutions... and especially timely since I just realized I want to be able to pause an Interpolate.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.