Have actor run away from mouse?

Greetings: I'm trying to have my actor run away from the mouse. Basically, the player touches the actor and it scoots away from the touch. Any idea on how to do this? Thanks!

Comments

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

    Accelerate towards mouse x, mouse y, speed -100.

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

    Or use move, or move to, or change velocity . . . . etc.

  • Larry WintersLarry Winters Member Posts: 13

    Thanks so much for this! Testing it out, I think I want it more to look like the player touches the actor and then the actor moves to random points on the screen. Would I do that with change attribute self.position X,y?

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

    @Larry Winters said:
    Thanks so much for this! Testing it out, I think I want it more to look like the player touches the actor and then the actor moves to random points on the screen. Would I do that with change attribute self.position X,y?

    It you used change attribute then the actor would instantly jump to the new position, instead it might look better if you interpolated the actor's position to its new value.

    Make a couple of attributes for the actor's target destination, let's call them TX and TY

    Rule: when touch is pressed
    --change TX to random (0,1024)
    --change TY to random (0,768)
    --interpolate self X to TX
    --interpolate self Y to TY

  • Larry WintersLarry Winters Member Posts: 13

    This is very helpful! Thank you! Works great!

Sign In or Register to comment.