Actor keeps moving in direction of touch

Gamer2125Gamer2125 Member, PRO Posts: 8

Hi, I need to create an actor which keeps on moving in vertical direction when game starts. When player touches the screen then it changes its direction and keeps on moving in that direction but it never stops.
I think this might be already discussed somewhere but I am not able to find. Can anyone please help me?

Comments

  • MoikMoik Member, PRO Posts: 257

    Do you mean the actor always moves vertically, but changes what direction it faces? I believe that would just be a Touch condition with an Accelerate Toward behavior for self.rotation.
    Or, would you be looking for an actor that always moves vertically, faces vertically, but can be dragged to different horizontal points? I believe that's a Touch constrained with SelfY to MouseY (no constrain to X)

  • Gamer2125Gamer2125 Member, PRO Posts: 8

    Sorry I wasn't clear earlier. At start of game actor is facing up and moving in vertical direction. Now for example when user touches on the right side of the screen then actor faces right and starts moving in right direction with same speed as earlier.

    I just want my actor to be able to face and move with a constant speed to a direction of touch.

  • MoikMoik Member, PRO Posts: 257
    edited May 2014

    Are you looking for constraining it to 90° angles, or just "go toward touch"?

    I believe Go Toward Touch would just be two Accelerate Toward behaviours for MouseX and MouseY. Not sure how constraining it to right-angles would work.

  • SocksSocks London, UK.Member Posts: 12,822
  • Gamer2125Gamer2125 Member, PRO Posts: 8

    Moik - Thank you for your help.
    Socks - Thank you so much for your demo file, it works exactly I wanted. Thank you again.

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

    @Gamer2125 said:
    Moik - Thank you for your help.
    Socks - Thank you so much for your demo file, it works exactly I wanted. Thank you again.

    No problem, it's basically what @Moik said, just get your actor to head towards the Mouse X and Mouse Y.

Sign In or Register to comment.