I need to swing the ship on 2D

Hello community.

I need to swing the ship when I push the buttons up and down. How I can do this?

I know that in 3D mode I can do it with those lines

public float tilt;

rigidbody.rotation = Quaternion.Euler(0.0f, 0.0f, rigidbody.velocity.x * -tilt);

There’s a way to do the same action on 2D? Or I need to do an animation or something similar?

Thanks for the help.


Based on your sample code this will work in 2D:

public float tilt;

rigidbody2D.rotation = rigidbody2D.velocity.x * -tilt;