0 votes

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 selectedspellinstance 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
in Engine by (30 points)

1 Answer

+1 vote

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.

by (12,649 points)

thank you very much!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.