How would I make a Rigidbody2D rotation follow its trajectory?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By quackandcheese

I’m trying to make a Badminton game as my first game in Godot, and I’m having troubling figuring out how to make the birdie have accurate physics. More specifically, whenever I hit the birdie (applying an impulse) it spins out of control instead of following its trajectory like it would in real life. I’m using a Rigidbody2D for the birdie, and these are my settings: Birdie

2D View

:bust_in_silhouette: Reply From: Skript-Kitty

Not sure if this fully answers your question, but the way I would implement the rotations would be to write this in the RigidBody2D’s code.

func _process(delta):
	$sprite.rotation = get_angle_to(self.linear_velocity)

get_angle_to ( Vector2 — Godot Engine (stable) documentation in English ) Takes a Vector2 and returns a direction in radians (Hence why you use $sprite.rotation instead of $sprite.rotation_degrees)

Also you can switch linear_velocity for whatever Vector2 you’re using to move the RigidBody2D.

Not sure if I fully understood the question, but I hope I was able to help!