View Full Version : Gmae help
KIERIOSHIMOTO
July 4th, 2005, 08:41 AM
Im working on this game, im not gonna say much about but i do need help with this,
ive got my guy rigged to move with the directional keys but i need a form of rotation, i was thinkink like this swf attached accept instead of using the directional keys i want to use the mouse
KIERIOSHIMOTO
July 4th, 2005, 08:43 AM
so pretty much what im trying to say is, i want my mc to rotate acording to my mouse, so where every the mouse faces , my mc is facing that way aswell
Rainman
July 4th, 2005, 09:32 AM
Hey there Kierioshimoto,
I found the following.
First make sure your gunturret is turned to the right. Apparently this is important for the script to work properly.
Add this action to the MC:
onClipEvent(load){
X = this._x;
Y = this._y;
}
onClipEvent(mouseMove){
Xm = _parent._xmouse;
Ym = _parent._ymouse;
Xdiff = Xm - X;
Ydiff = Ym - Y;
radAngle = Math.atan2(Ydiff , Xdiff);
this._rotation = radAngle*360/(2*Math.PI);
updateAfterEvent();
}
First, the onClipEvent(load) action calculates the original position of the clip in X and Y variables.
Each time the mouse is moved (onClipEvent(mouseMove)), the following actions are executed:
First of all, the mouse position is recorded in two variables, Xm and Ym. Then the difference between these and the original position of the clip is calculated, and stored in Xdiff and Ydiff. The (0,0) , (0, Xdiff) and (Xdiff , Ydiff) points form a right angle rectangle, so the angle between the positive side of the X axis and the mouse is simply calculated with an 'arc tan' function. This rotation is translated from rads to degrees, and this is the angle that's finally applied. To keep everything smooth, an updateAfterEvent() action is added; this way, the clip can follow the mouse at 60 fps, even if the movie is set at 12 fps.
KIERIOSHIMOTO
July 4th, 2005, 09:41 AM
i found that too but look at my swf, i want him to stay in one spot
Rainman
July 4th, 2005, 09:44 AM
I think you have to place the pivot point in the center of your MC... can you post the fla file?
KIERIOSHIMOTO
July 4th, 2005, 09:48 AM
i tried that but here it is
Rainman
July 4th, 2005, 10:03 AM
Here it is, not perfect yet, but with a little work you'll be able to keep it in the ecaxt same place. You should first create the sphere, then make sure the pivot point is in the center and then create the arms.
game.fla (http://www.rainman.nl/swiftdev/game.fla)
KIERIOSHIMOTO
July 4th, 2005, 10:08 AM
thanx man but could u set me an example of how to equip one on the guns in the library to the mc, or just write a little tut 4 me on it
? that'd b great
KIERIOSHIMOTO
July 4th, 2005, 10:09 AM
can u attach it to ur message (the game.fla) ur site wont work fore me
be back in a few minute im having a shower
Rainman
July 4th, 2005, 10:14 AM
Well, I don't have a lot of knowledge about gaming and AI so maybe someone else can help you with that....
Attached the file now :D
KIERIOSHIMOTO
July 4th, 2005, 10:21 AM
ok thanx 4 ur help anyway dude
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.