Hi there, thanks for looking at this thread. Been frustrated tonight and could use your help.
This is a pretty long list and i appreciate any of the help I can get. I attempted to format this as best i could so you can see the points where i need help.
Code is down below for the function atm
Thanks In Advance.
CONTEXT
Farmer is defending his barn and needs to shoot enemies that are airborne and on the ground fluidly.
Needs to load either facing right or left for weapon clips
While aiming weapons/arms need to rotate
Need to have a point where bullets/particles will spawn and needs to be consistent through rotating.
PROBLEM ONE
I have a rifle, spud, and bow weapon movieclips with 2 frames, facing right and facing left.
the character doesn’t move, only his arms holding the weapons. and im trying to get the right/left animation to load properly on the enter frame since weapons will be switched. once i get a base then i can extend it to the other weapons and work on the actual rotating of the arms/weapons based on where the farmer is aiming.
PROBLEM TWO:
in addition currently if i enable the rotating, the gun rotates w ildly and not fluidly like i want. I need it to gradually rotate up and down based on where the armer is aiming and from the stock of the gun not the middle. (I remember being able to adjust this in Flash 8 and it would remember if u moved the pivot point.) Why doesnt cs5 ever remember the pivot point change?
PROBLEM THREE:
the last complication would be can i add a simple point, and wherever the weapons are rotated will that point move as the weapon rotates to shoot?
for now ive constructed the objects in the main document class but plan to have a weapon base class and then extend that for the weapons.
I tried both radians and degrees and its iffy, Just been taking the mouse from to the upper left of the farmer down to the lower left, and the upper right of the farmer to where the lower right. and checking the values. but cant seem to get it to accurately switch facing right or left. I tried both degrees and radians.
addEventListener(Event.Enter_Frame, moveWeapon);
public function moveWeapon(event:Event):void {
var dx:Number = mouseX - rifle.x;
var dy:Number = mouseY - rifle.y;
var radians:Number = Math.atan2(dy, dx);
var angle:Number = Math.atan(dy/dx)/(Math.PI/180);
trace(radians);
if(stringWeapon=="Rifle")
{
if(radians <= 1.49 && radians <= -1.554)
{
//Go to facing left frame for rifle
rifle.gotoAndPlay(1);
}
else if (radians <= -1.5 && radians >= 1.45)
{
//Go to facing right frame for rifle
rifle.gotoAndPlay(2);
}
}
else if (stringWeapon=="Bow")
{
}
//Rifle Pivots up and down for facing right/left animation based on where user is aiming.
rifle.rotation = radians* 180/ Math.PI;
Thanks in Advance.