I'm trying to figure out how to place a bullet mc at the tip of my gun depending on its rotation...?
Printable View
I'm trying to figure out how to place a bullet mc at the tip of my gun depending on its rotation...?
x = circle's center + cos( angle ) * radius;
y = circle's center + sin( angle ) * radius;
where angle is in radians
ps: circumference is the length of a circle's perimeter.
I've set it up like this...
ammo._x = _root.gun._x + Math.cos(_root.gun._rotation) * 50;
ammo._y = _root.gun._y + Math.sin(_root.gun._rotation) * 50;
and it's not working correctly? what did I do wrong?
the guns x and y would be the center, and the gun is 50 pixels long so 50 would be the radius right?
MovieClip's _rotation property is in degrees, not radians. So you need to convert to radians:
radians = degrees * pi / 180
oh snap thats right ty ty!
works perfectly!
I think tangent would be better to use. and use ATAN2() to get degrees