Unity2D move + turn with a fixed angle

Hello,

i have a question about moving a sprite object.

I’m using a rigidbody2D and i want a constant speed.

So i used rigidbody2D.velocity ( Maybe .AddForce is better but i want that the speed never fade away. And with Force it does :(.)

So when i press the left/right key the object should make a curve by a fixed angle.

Curve Fever | Play the online multiplayer game ( Just click play ) Like this game >.<

Maybe someone can help me.

Regards

LifeArtist

I’m assuming the ‘forward’ of your ship is the ‘up’ direction when the rotation is (0,0,0). Your code should be executed in FixedUpdate(). Try this to address your problem:

void FixedUpdate() {
	if (Input.GetKey(moveRight))
	{
		transform.Rotate(0F, 0F, 7F);
	}
	if (Input.GetKey(moveLeft))
	{
		rigidbody2D.AddForce(transform.up * 5F);
	}
}