Changing direction on touch

AngryBoiAngryBoi Member Posts: 586

Okay, so I have an actor that is moving in a random direction to start out. How would I make it so when I press on the actor, It starts going the opposite direction?

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    When touch is pressed change the velocity of the actor to a negative number (or simply multiply the current speed by -1)

  • Nate_SNate_S Nate - Pixel Artist - Developer - Graphics Designer Member Posts: 86

    To clarify
    If: Touch is pressed.
    Do: Change attribute: Self.Motion.Linier Velocity.X(or Y) To: (Self.Motion.Linier Velocity.X-(Self.Motion.Linier Velocity.X*2))

    **Nate - Pixel Artist - Developer - Graphics Designer **

  • Nate_SNate_S Nate - Pixel Artist - Developer - Graphics Designer Member Posts: 86

    the formula us basically multiplying itself times 2 because itself times 2 Minus Itself = The Oposite.

    **Nate - Pixel Artist - Developer - Graphics Designer **

  • AngryBoiAngryBoi Member Posts: 586

    I don't think i explained well enough. With the way you guys explained, you are using linear velocitys x and y. I am just using "move." If I use the velocitys, how do i go in a random direction?

  • SocksSocks London, UK.Member Posts: 12,822

    @TappWater said:
    I don't think i explained well enough. With the way you guys explained, you are using linear velocitys x and y. I am just using "move." If I use the velocitys, how do i go in a random direction?

    When touch is pressed change the velocity of the actor to a negative number (or simply multiply the current speed by -1)

  • AngryBoiAngryBoi Member Posts: 586

    How do I go diagonally?

  • AngryBoiAngryBoi Member Posts: 586

    Or how do I change it to go in a random direction, but with always having the same speed?

  • SocksSocks London, UK.Member Posts: 12,822

    @TappWater said:
    How do I go diagonally?

    In the Move behaviour change the direction setting to a diagonal direction (45°, 135° etc)

  • SocksSocks London, UK.Member Posts: 12,822

    @TappWater said:
    Or how do I change it to go in a random direction, but with always having the same speed?

    In the Move behaviour change the direction to a random angle.

  • AngryBoiAngryBoi Member Posts: 586

    @Socks Yeah but now I already have change velocity happening. The move behavior doesn't work with this already happening.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @TappWater said:
    Socks Yeah but now I already have change velocity happening. The move behavior doesn't work with this already happening.

    Sorry, I don't know what any of that means. :/

Sign In or Register to comment.