How can I measure an angle from one x,y to another x,y? (And send a bullet that direction?)
findmattgames
Member, PRO Posts: 100
I want a bullet to shoot towards my touch point from an x,y of 160,160.
I have my variables set up to store what each x and y is on touch. I can do that. I know where I spawn the bullet at 160,160. Now I need the bullet to travel at the angle from 160,160 to TouchX,TouchY.
Now I can to a move to with direction, but that stops at the destination. I need something that gets the bullet to travel infinitely at the measured angle. Thoughts?
Comments
With the regular MOVE action, I set the direction to
vectorToAngle(( game.BulletX -160),( game.BulletY -160))
and that works perfectly.
However with each new bullet that spawns it takes the new direction. Any idea how to keep each bullet on its original path?
Is there a badge for answering our own questions? I'd delete it but this may help others.
Transfer the values of touch x and touch y to two local (self) attributes - and use these for the bullet's direction.
Ah, yes. Thank you!