DigitalHax Posted May 5, 2012 Share Posted May 5, 2012 Hey, I am currently trying to sort out animation for my character, and I need a way of letting the animator know that the player is turning. Here is my code - TVec3 PivotRotation=Vec3(0); //Camera looking mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); dx=Curve(MouseX()-GraphicsWidth()/2,dx,28); dy=Curve(MouseY()-GraphicsHeight()/2,dy,28); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; cam2rotation.X=cam2rotation.X+dy/10.0; cam2rotation.Y=cam2rotation.Y-dx/10.0; RotateEntity(pivot,camrotation); RotateEntity(campivot,Vec3(camrotation.X,camrotation.Y,0)); EntityParent(camera,campivot); PositionEntity(mesh,EntityPosition(player)); So any suggestions on how I can specify if it is turning? Thanks in advance. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
gamecreator Posted May 6, 2012 Share Posted May 6, 2012 I would simply use EntityRotation to compare the current value to the previous frame's. If they're not the same, the entity rotated. Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted May 6, 2012 Author Share Posted May 6, 2012 Hmm... That might work. But im a bit of a noob to stuff involving timing in LE. :/ What sort of code could I use for a frame check? Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted May 6, 2012 Share Posted May 6, 2012 You don't need to use timing at all. You simply need to store the value of the last rotation and then compare it to the current rotation. Then if the difference is enough to warrant a turning animation then you tell it to animate. //In class declaration float lastRotY; //In the your update function or whatever you call it if(lastRotY-EntityRotation(player).X>= [a value here]){ //Play Turning Right Animation } else if(lastRotY-EntityRotation(player).X<= [a different value]){ //Play Turning Left Animation } Do something like the above. Though you will have to make up for the fact that when you get to 360 degrees it loops back to 0 but I'll let you figure that out. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Benton Posted May 6, 2012 Share Posted May 6, 2012 ...make the model turn when the turn key is pressed... Quote Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D Link to comment Share on other sites More sharing options...
DigitalHax Posted May 6, 2012 Author Share Posted May 6, 2012 I use mouse X movement. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Benton Posted May 7, 2012 Share Posted May 7, 2012 Ahh, it's MouseXChange = PreviousMouseX - CurrentMouseX that gives you the change. If MouseXChange > 0 then it's turning left i think. Now every frame rotate the camera, multiplying by appspeed. I think that should work. Quote Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.