Stencyl 3.4.0 is now out. Get it now!

Firing in opposite direction of mouse (speed)

Optimos

  • Posts: 16
Hi.
I'm making a game where you click on an actor and, while held down, you drag the mouse anywhere in the screen so when you release it the actor is fired in the opposite direction. I got it right thanks to a block called atan2, but there's still something that I can't get clear: I want to make it so that the further the mouse is released from the actor, the faster the actor will be fired in the opposite direction.

I tried creating a circular region at (x: x-center of actor / y: y-center of actor) and the radius would be the distance between the center of the actor and the mouse at the exact moment of releasing, but I can't find out how to get the radius :(

Can anyone help me? Thanks in advance.

svintaj

  • *
  • Posts: 275
This is how I did to get the distance between two coordinates 'MouseXY' and 'LastXY':

Optimos

  • Posts: 16
This is how I did to get the distance between two coordinates 'MouseXY' and 'LastXY':
That worked!!
I then made a new attribute called 'Player speed' and set it to Distance/7. Now if the distance is too long it moves really fast and if it's shorter it moves slower.
Thank you!!!