Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

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

This question already has an answer here:

I would like to rotate my Player very smooth. At the moment the player stops rotating when I release the button. Also the rotation should get faster, if the player rotates longer. I use XNA and have no idea how to solve this.

Sry for my english, I hope you understand what I mean.


share|improve this question

marked as duplicate by Byte56, Sean Middleditch, Josh Petrie, Trevor Powell, bummzack Feb 13 '13 at 8:48

This question was marked as an exact duplicate of an existing question.

up vote 0 down vote accepted

you could try something like this

float turnSpeed;
if (KeyBoard.GetState().IsKeyDown(Keys.Right))
if (KeyBoard.GetState().IsKeyDown(Keys.Left))

 RotationAngle += turnSpeed;
 //Adjust what you multiplay turnSpeed for how long you want him to stay spinning.
 turnSpeed *= 0.89f;

He should now speed up while turning, then when you release the turning keys on the keyboard he should spin a tiny bit then stop.

share|improve this answer
Now the rotation is smooth, although he doesn't speed up... – user26188 Feb 11 '13 at 13:28
This code initializes a new variable called turnSpeed each update, meaning it never changes in magnitude because it is always initialized to its default value each time. You need to use a variable that maintains an appropriate scope for your rotational velocity. – Evan Feb 11 '13 at 14:19

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