Jump to content

Turning


DigitalHax
 Share

Recommended Posts

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.

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

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?

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

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.

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

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.

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...