cancel interpolate problem

ApplaudAppsApplaudApps Member Posts: 308
edited November -1 in Working with GS (Mac)
Evening,

I've got a level preview going on where the camera tracks up and down the scene before play starts and I've got a skip button.

What I want to happen is that when the skip button is touched the camera goes immediately to Y position zero and play starts i.e. the preview is cancelled and camera is back at the start position at the bottom of the scene (which is double height)

But what I'm getting is that the first part of the preview interpolate instruction that moves the camera up the scene still completes and then freezes at the top of the scene because the skip part of the program has already happened (you see a brief flash where the camera goes to the zero position and then resumes where the interpolate has got to)

Is there no way to cancel an interpolate mid run? Any workarounds that you can help me with? Thanks in advance. Philip.

Comments

  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    No, interpolate can not be interrupted. I think you're going to have to use linear motion or one of the other movement options if you want it to be able to be interrupted.
  • spliketspliket Member Posts: 93
    i'm guessing you have multiple interpolates running in series?

    i would add a rule after each interpolate to check to see if "skip" has been pressed. so, when skip is pressed it changes a skip attribute to 1.

    then, after the first interpolate, it checks to see if skip=1. if it does, then it jumps right to where you want the camera to be....so, it wouldn't be an instant "skip"...it'd be delayed, but it might be better than nothing.
  • SparkyidrSparkyidr Member Posts: 2,033
    I can't remember the specifics off the top of my head.
    But....

    When you register a press of the skip button, if you interpolate the x and y vaue of the camera, to the x and y value for 0.1 seconds or something, and then do the skip camera interpolate, I think that might work.
    If not...it will at least do something different :o)

    This worked for me when I had a problem with interpolating the size of something one way, and then back the other way, I had to hard code in this sort of re-set....but like I say, not sure if it's the same process for what you need.
  • ApplaudAppsApplaudApps Member Posts: 308
    spliket said:
    i'm guessing you have multiple interpolates running in series?

    Yeah I have two chained interpolates both on the Y axis - one that looks up the scene and the other that returns to the start position. I had already tried your suggestion and unfortunately it still results in at least part of the chain completing.
    Sparkyidr said:
    When you register a press of the skip button, if you interpolate the x and y vaue of the camera, to the x and y value for 0.1 seconds or something, and then do the skip camera interpolate, I think that might work.
    If not...it will at least do something different :o)

    Cheers - that sounds interesting. So maybe one interpolate overwrites the other? I'll definitely try that tonight.... and yes if it doesn't work it'll be different...and thats all good ;-)
    SlickZero said:
    No, interpolate can not be interrupted. I think you're going to have to use linear motion or one of the other movement options if you want it to be able to be interrupted.

    Slickzero - thanks for confirming that!

    I'll report back if I find a working solution.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    The only way to cancel an interpolated is with another interpolate.

    So use interpolate on the x and y when the skip button is press and it should circumvent the rest of them from happening. But you will also have to make sure you do something to invalidate the rule that starts the first interpolate.
  • ApplaudAppsApplaudApps Member Posts: 308
    I've tried that and it didn't work. I've got :

    rule 'skipped' = false {
    interpolate cameraY to 640 2.5 seconds
    rule cameraY = 640 {
    interpolate cameraY to 0 2.5 seconds
    }}

    otherwise {
    interpolate cameraY to 0 0.1 seconds
    }

    I've also tried a separate rule if skipped = true instead of the otherwise.

    What happens is it quickly interpolates to 0 and the continues the first interpolate up to 640 then stops i.e. it cancels after that and doesn't return down.

    So the skipped interpolate happens (just like my original change attribute happened) but it doesn't appear to overwrite/cancel the original interpolate, only temporarily interrupt it.
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    Just for giggles, try using linear motion instead of interpolate.
  • ApplaudAppsApplaudApps Member Posts: 308
    Do you mean with moveto? moveto never works for me (known bug?) I just tried it and it didn't move at all.

    Plus I really wanted to use the easing you get with interpolate.

    edit : moveto is instant isnt it rather than an animation? that's why it didn't work.

    What do you mean by linear motion?
  • ApplaudAppsApplaudApps Member Posts: 308
    Totally solved it! :D

    I added an actor attribute called previewY, constrained the actor.position.Y to previewY, interpolated the previewY value to do the scene preview up and down.

    When 'Skip' is touched constrain actor.position.Y to actor.position.Y which cancels the preview interpolate since its no longer following it (even though the original interpolate is still going on)

    Works perfectly and no memory issues. Hope this might help someone else.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I haven't made a demo for anyone in a while so you are the winner. LOL

    http://gamesalad.com/game/17982

    Search Scene Preview in the gamesalad new tab and you should be able to download it
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    ApplaudApps said:
    Totally solved it! :D

    I added an actor attribute called previewY, constrained the actor.position.Y to previewY, interpolated the previewY value to do the scene preview up and down.

    When 'Skip' is touched constrain actor.position.Y to actor.position.Y which cancels the preview interpolate since its no longer following it (even though the original interpolate is still going on)

    Works perfectly and no memory issues. Hope this might help someone else.

    Dang I published it to late. LOL

    Take a look at that though its all interpolates no extra constrains or anything which is really good to avoid as many as you can.
    ___________________________________________________________________________________
    GS BubbleBall Template HERE!!
    Stacks Level Selection Template HERE!! Now only $20
    Expanding Option Menu Template HERE!!
    AppSolute Entertainment on iTunes
    AppSolute Entertainment on Facebook
  • ApplaudAppsApplaudApps Member Posts: 308
    Hey tenrdrmer, I really appreciate you going to the trouble. That was my original set up however and your demo has the same problem, I'm sorry to say. If you click 'start' followed by 'skip' really quickly while its running the first interpolate you'll see the problem > it jumps to '1' but then keeps running the interpolate and ends up with '2' in the middle etc. If you increase the time each step takes you'll be able to simulate the problem easier.

    Thanks anyway mate! :)
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Ah I see. I hadn't tried being crazy with the clicking LOL

    Thats an odd glitch I think I may actually send that to GameSalad as it should cancel out the interpolate its on and start a new one.
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    So in a round about way, interpolate CAN be interrupted?...Obviously...
  • UtopianGamesUtopianGames Member Posts: 5,692
    Now all we need is the actor to collide while interpolating!!!

    I have 2 actors one shrinking and one growing and GS doesn't register collision until both have interpolated ...aaahhhhh lol

    Darren.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I submitted that project to GameSalad. We'll see what they say. it has to be some sort of bug cause it works flawlessly as long as you don't switch it too fast.
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    I'd like to know the outcome from that.

    Applaud, I was talking about Linear Motion, you can get to the settings for this under the attribute browser. You would drag a change attribute behavior on the actor, and go Self.Motion - Linear Motion. And you have X and Y coordinates to manipulate, but no ease in and ease out like interpolate.
  • ApplaudAppsApplaudApps Member Posts: 308
    Just thought I'd let you know I've found (by accident) another way to cancel an interpolate.

    If the interpolate is within a timer with the "run to completion" box unticked then any change in the rules its being run under will cancel the timer instructions including interpolate!!

    edit: but only if another interpolate takes it place under a diffent rule/timer combo.
  • Rob2Rob2 Member Posts: 2,402
    I think this has been looked at from the wrong angle, rather than trying to interrupt the interpolate it has to be fed updated values. So if both the To and Duration are attributes then to stop a simple move you would update with a very short duration and the current location.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Hey I just wanted to share That I have never heard back from GameSalad on this however I have solved the issue from the demo where it doesn't interpolate back correctly. It works very nicely now. I'll be posting a better description of whats going on as well as a separate demo showing the new way I have come up with to cancel an interpolate.

    ___________________________________________________________________________________
    Project Help from Tenrdrmer Click Here

    GS BubbleBall Template HERE!!
    Stacks Level Selection Template HERE!!
    Expanding Option Menu Template HERE!!
    Tenrdrmer's Menu # 3 HERE!!
    Menu #4 - Level Banners HERE!!
    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
Sign In or Register to comment.