how to point a node towards it's velocity

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

how to point a rigidbody2d to point at it’s velocity , the node has it’s velocity given by its parent through aapplied_impulse
this is the whole line of code

selected_spell_instance.apply_impulse(Vector2(), Vector2(spell_speed, 0).rotated(rotation 
+ rand_range(-trembeling,trembeling)))

the selected_spell_instance is the node i added as a child , and the trembeling is a little quirk for the node to shoot in a little different direction everytime

and then i apply the rotation to the node

selected_spell_instance.rotation = rotation
:bust_in_silhouette: Reply From: Calinou

To avoid jittery rotation, you could store lerp() the node’s rotation by a certain amount every frame so it doesn’t occur instantly. You could also use the Tween node to do that.

Also, you may want to rotate only the node’s visual representation, rather than the whole RigidBody. This is especially true if your RigidBody’s collision is a circle or sphere, as there would be no point in rotating it on your own.

thank you very much! | 2020-05-12 11:45