Back and forth movement

Started by
2 comments, last by Just Chris 18 years, 4 months ago
Hey guys, How can i do back and forth movement? Like, let's say i there's a guy standing around and i want his head to move to 25 degrees, then -25 degrees, how would i do this? Thanks :) Mike
Advertisement
That's a really vague question. How are you displaying the guy? What programming language are you using? How long do you want his head to be facing each direction? How long do you want it to take for the facing to change? Do you want the change to be abrubt or smooth?
Are you in a 2D or 3D game?
JUST-CODE-IT.NETManaged DirectX & C# TutorialsForumsArticlesLinksSamples
If you are talking about a keyframed back-and-forth motion (like a Pong ball), most of the time you can control this with two variables. One variable tracks the angle of the guy's head and the other determines the speed at which the head is turning/rotating.

Just initialize these variables outside the function where the movement takes place, and inside the movement funtion check whether the angle passes the 25 or -25 degree limit and reverse the variable for the rotation speed.

This topic is closed to new replies.

Advertisement