Hello, I’ve been working on a project where the upper body is controlled via the mouse, and the lower body down is controlled by the directional keys w,a,s,d. Here’s the dilema: I managed to get the w,a,s,d keys to work; however, it doesn’t act like a car. I wish to make the movement to go foward when “W” is pressed regardless if it points north,east,west,and south, etc. vise-versa with “s”. And for “a” and “d” move counter wise /clock wise
help is much appreciated.
And also as a bonus, it would be really nice if all my actionscript could be replaced from a clip event to a script, all done in one frame.
Thanks
For those who hate to d/l fla’s
this is the clip event on the characters “body”
onClipEvent (enterFrame) {
x=this._xmouse;
y=this._ymouse*-1;
angle = Math.atan(y/x)/(Math.PI/180);
if(x<0){angle+=180}
if(x>=0&&y<0){angle+=360}
_root.angletext=angle;
_root.arrow._rotation=angle*-1;
//Basic movement
if (Key.isDown(87)){
_y -= _root.speed;
_root.arrow._y -=_root.speed;
}
if (Key.isDown(83)){
_y += _root.speed;
_root.arrow._y +=_root.speed;
}
if (Key.isDown(65)){
_x -= _root.speed;
_root.arrow._x -=_root.speed;
}
if (Key.isDown(68)){
_x += _root.speed;
_root.arrow._x +=_root.speed;
}
}