Use interpolate to make animation occurs problem
Hello everyone!
I have a problem about interpolate.
I usually use interpolate to make animation.
For example: A actor move up and down.
But always occurs bug?
I made a button to control the actor to move to Position.A(100) and Position.B(-150).
And the actor will move up and down when it position=100.
But when I touch the button again, it sometimes can't back.
Sometimes working, but sometimes not.
Please help me.
What should I do?
↓↓↓There is my GS behaviors and Gif.↓↓↓
Button
When Touch
Do Change Attribute A.Boolean = not(A.Boolean)
Actor
When A.Boolean = true
Do interpolate self.position.y = 100 / 0.25s
Else interpolate self.position.y = -150 / 0.25s
When self.position.y = 100
Do interpolate self.position.y = 150 / 0.25s //this behavior is move up.(cycle)
When self.position.y = 150
Do interpolate self.position.y = 100 / 0.25s //this behavior is move down.(cycle)
Comments
@Weiyu
You have a "-" here "Else interpolate self.position.y = -150 / 0.25s"
When testing for a position, use "<=" and ">=". If you only use "=" to test for a specific position, then the Rule will usually miss that specific value, because the actor X and Y position is a real number (e.g. 150.5342) and because the actor may be moving to fast.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
This is why typing out your code is often a pointless exercise, if you've made a mistake in your code (an extra comma in an expression, a rule accidentally switched off . . .etc), then who is to say you will not unknowingly auto-correct when typing it out, or who is to say you won't also make another separate/new mistake in your typed code !?
A screenshot will show us what the code is doing, everything else is subject to transcription errors of various kinds.
I'm not sure that applies to the Interpolate behaviour, Interpolate will always hit the target number - that's why it uses a duration value rather than a pps value like other behaviours like Move.
That is why I said "when testing", implying rules. Guess I need to be more clear.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Yeah, that's what I'm saying, even for rules when using an Interpolate !
With an Interpolated actor targeting X=156, you can quite safely use when X = 156, as Interpolate will always land on exactly 156.
Quite right, fair point.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch @Socks
Thanks for your help, you do gave me a big favor.