Holmesc
February 11th, 2007, 11:45 PM
I'm trying to create a turret that will rotate so that it is pointing at the mouse. Without the knowledge to make it happen, I sifted through tutorials until I found some code, which I adapted to my circumstances. However, the code was made to rotate towards an MC that only moved horizontally, which may be why it doesn't work... Anyhow, here's the code:
ActionScript Code:
onEnterFrame = function () {
angle = Math.atan2(_root._xmouse-_root.turret._x, _root._ymouse, _root.turret._y)/(Math.PI/180);
_root.turret._rotation = angle;
};
Yes, relatively simple code, but as I'm not the greatest at math, I need a little help straightening this out. Thanks for your help!
ActionScript Code:
onEnterFrame = function () {
angle = Math.atan2(_root._xmouse-_root.turret._x, _root._ymouse, _root.turret._y)/(Math.PI/180);
_root.turret._rotation = angle;
};
Yes, relatively simple code, but as I'm not the greatest at math, I need a little help straightening this out. Thanks for your help!