Little help with as

can someone please give me a simple as code to have an mc (man) rotate to where the mouse is and when (MouseDown) occurs make a bullet mc (ball) fire in the direction that the man is facing because every code i make will not fire in the direction, it goes off at weird angles im not quite sure how to calculate the direction for it to move fowards

any help is apreciated

thanks
woopsedoo:sen:

A simple way is

bulletSpeed = 3;
man.onEnterFrame = function(){
this._rotation = Math.atan2(this._y-_ymouse, this._x-_xmouse)/180*Math.PI-180;
}
onMouseDown = function(){
bulletMC.duplicateMovieClip("bullet"+i++, i, {_rotation:man._rotation, onEnterFrame:function(){
this._x+=Math.sin(this._rotation/180*Math.PI)*bulletSpeed;
this._y-=Math.sin(this._rotation/180*Math.PI)*bulletSpeed;
}});
} 

May need a little tweaking, but Maths isn’t my forte, if it’s not right, let me know :stuck_out_tongue:

thanks a lot:hugegrin: :hugegrin: :hugegrin: :hugegrin: :hugegrin: :hugegrin: :hugegrin:

sorry but the code or the man rotatingi didnt actualy nee but im afraid the code you gave me about the bullet dosnt work

can anyone please help

ive changed the code but it still isnt working can anyone correct me on


bs = 3;
Key.SPACE.onKeyDown = function() {
 bullety.duplicateMovieClip("bullet"+i++, i, {onEnterFrame:function () {
  this._x = _root.man._x;
  this._y = _root.man._y;
  this._x += Math.sin(this._rotation/180*Math.PI)*bs;
  this._y -= Math.sin(this._rotation/180*Math.PI)*bs;
 }});
};