Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the regular (linear) motion implemented like this:

class Craft{
Vector location, velocity, acceleration, angularVelocity, angularAcceleration;

//the move class responsible for linear motion
//this method works
 public void move(Vector target){
  Vector desired = target.sub(location);

//the turn method 
//I need help/tips

public void turn(float angle){
//I need the craft to gradually turn in a circular motion
// so that eventually maybe 10 secs, it makes 360 degrees turn


share|improve this question

Angular acceleration works just like linear acceleration on a single axis, except instead of working with a distance, you're working with angles.

So, for example, lets look at your linear motion converted into a single axis:

float desired = target - location;
//perform something similar to normalize, where you limit the size of `desired`
acceleration = desired * speed;
velocity += acceleration;
location += velocity;

We can easily imagine this to be converted using angles instead:

float desiredAngle = targetAngle - currentAngle;
//perform something similar to normalize, where you limit the size of `desiredAngle `
angularAcceleration = desiredAngle * speedOfRotation;
angularVelocity += angularcceleration;
currentAngle += angularVelocity;

Note: You may want to add your timestep into this equation, otherwise you'll have to set speed and speedOfRotation to something like: desiredSpeed * timestep. Basically, speed and speedOfRotation should already have the time factored in if you don't include it separately.

It would be preferable to add some kind of wrapping code to wrap currentAngle when it completes a circle, but it's not strictly necessary.

share|improve this answer

One solution is that you can have the method create a thread that adds 1/10 of a whole turn then sleeps a sec, then adds another 1/10 and so on until you have done that 10 times. Just remeber angles are usally measured in radians rather then degrees. You should also put up some safe guards so while a tread is active, you cant call the method until the other tread is finished. You should also make a conditional statment so whenever the angle reaches 2 pi you reset it to 0 again, otherwise it can get big really fast.

But that just one way you can do it, depends all on how much performance you want to use

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.