make an actor move a specific distance

geoffygeoffy Member Posts: 13
edited November -1 in Working with GS (Mac)
Might be pretty easy to do but I can't figure it out. I want to make an actor move only a certain distance when touched. basically want to make an actor jump from one place to the next, but only allow the actor to jump a certain distance. Appreciate some help with this, and sorry if it's been asked and answered before. Cheers

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    if you want it to jump to the next place you can do when touch is pressed change attribute self position x to self position x +1 or any amount of pixels you would like
  • geoffygeoffy Member Posts: 13
    Thanks, that works, but the problem i now have is that my actor could be facing any direction so is there a way i could make him move in whatever direction he is facing?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Your gonna need 2 booleans attributes. Ill call them walk left and walk right as an example.

    Basically when the actors facing right change walk right to true. In the actor have when touch is pressed and walk right is true change attribute self position x to self position x+1

    then when hes facing left change attribute walk left to true. Have a rule when touch is pressed and walk left is true change self position x to self position x -1.

    Make sure that when one is true, you change the other one to false
  • geoffygeoffy Member Posts: 13
    sorry I should have been clearer. The actor could be facing any direction in 360 degrees not just left and right. So basically I need a way of capturing the direction that the actor is facing, and then somehow calculate the x and y coordinates to move him to.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    ahh sorry didnt understand

    have a attribute called move

    in the actor have a rule when touch is pressed change attribute move to 1
    then in that same when touch is pressed rule drag in a timer have it after 0.1 seconds with run to completion checked then put a change attribute behavior in the timer and change move to 0.

    Then make another rule when attribute move =1
    then drag in a move behavior. leave the direction to 0, next to direction where it says relative to make sure its relative to actor. And you can leave the speed at 300
  • geoffygeoffy Member Posts: 13
    So what is the timer actually doing? I haven't tried this yet but it looks like it will make the actor move in the direction he is facing, I just don't get why I need the attributes and timer. I also need him to stop moving after a certain distance.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    the timer makes it so it only moves for 0.1 seconds, which is only enough time for it to move 1 spot in the direction its facing. Its the easiest way to do it and explain,
  • geoffygeoffy Member Posts: 13
    ah ok cheers, i'll give it a go. Thanks mate
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    anytime :)
  • geoffygeoffy Member Posts: 13
    worked perfectly, thanks for your help.
Sign In or Register to comment.