Controlling an actor's movement with other actors

daniel.robert.campbelldaniel.robert.campbell Member Posts: 251
edited November -1 in Working with GS (Mac)
I'm officially at a dead end.

I have a crosshair on screen used for aiming. I need it to move left and right, and ONLY left and right (not up and down). I have a left arrow, and a right arrow to do so. When each is pressed, I have a rule that when (Touch inside + Touch pressed) they change a "move crosshair left" or "move crosshair right" attribute to +1.

I also have an additional rule on each arrow that is (touch inside + touch released) causes those same attributes to -1.

On the Crosshair I have a rule that says if "move crosshair left/right" is > 0, accelerate left/right. The crosshair does this, but it will not stop when the arrow is released.

If the crosshair is still in motion and I press the opposite arrow (moving left, I hit the right arrow) then the crosshair will stop, but will not respond after that.

Any advice I could get would be GREATLY appreciated. Thank you for your time.

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    You can take out the touch inside rules and have it when touch is pressed. Also make it when touch is pressed change attribute to 1 and when touch is released change attribute to 0. you dont have to use +1 and +0.

    And heres the real answer to your question lol. When you use accelerate and dont apply drag, the acceleration happens until its reach its top speed, So if you have accelerate speed 100 and you let go of the button before the speeds 100 it will keep acelerating until it reaches 100. So just use move and make it relative to scene and youll be set.
  • Awesome. I will give that a try as well. I also tried it with the "Move" behavior but sadly I got a very similar result. :-(

    I'll let you know how your advice turns out though. Thanks!
  • Worked like a charm my friend. I'm not sure if it was the "inside" problem or the +1/-1 problem but it fixed it either way. Thank you so much for your help. /hug
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    anytime, glad it worked for you :)
  • Although it works INFINITELY better now (Thanks a ton JohnPapiomitis), it does still act a little wonkey sometimes. When I double tap or hold for too long, it tends to malfunction.

    Is there a cleaner way to handle this type of behavior? A more reliable way that might not result in bugs?

    Sorry I'm such a noob. And thanks again to JohnPapiomitis.
Sign In or Register to comment.