Probleme with start/stop via interpolate-function, look at my script

akimannakimann Member Posts: 62
edited November -1 in Working with GS (Mac)
Problem: I have two actor: One Start/Stop Button an a moving actor.
I want to move the actor from left to right when the Button is clicked. When I click the button again, the actor should move back to the start position and stay there. When I click the button once more, it should start moving again from left to right. But with my script it doesn´t work.

When I click start first, everything works fine. When I click the Start/Stop-button again the actor moves back to the start position but after this he is jumping back to that position from where he moves back and keep on moving from left to right *why???* :-(

For the Clickbutton I do have the script:

When touch is pressed
Change Attribute <game.xxxx> to (game.xxxx+1)%2

that results to change the value xxxx in "1" or "0" after each click

Here´s the script from the moving actor:

When Attribute <game.xxxx= 1
interpolate attribute <self.Position.X) to 320
Duration 5 Function <linear>

Otherwise
interpolate attribute <self.Position.X) to 0
Duration 1 Function <linear>

That´s all

But where is my ugly bug???

Comments

  • b2iscoolb2iscool Member Posts: 135
    just copy the rule that moves the actor then drag it into the otherwise section and change the game.xxxx part to 0
  • akimannakimann Member Posts: 62
    Hi b2iscool, thank you for your help, but this also doesn´t work. I´m really going mad, because I don´t have any idea where the bug is :-(
  • akimannakimann Member Posts: 62
    Yeah, now I found the solution that works :-)

    instead of
    "interpolate attribute <self.Position.X) to 0"

    I used

    "constrain attribute <self.Position.X) to 0"

    didn´t guess why this works perfect, but it works an I´m going to have a bear now :-)
Sign In or Register to comment.