Topic was automatically imported from the old Question2Answer platform.
Asked By
Abgenullt
Old Version
Published before Godot 3 was released.
Hello,
I have a rigid body with the body_enter signal connected.
How can I get information about the impact of the collision inside of the signal method?
I want to react to it in some way.
Thank you!
By impact, do you mean the relative velocity of the collision?
Bojidar Marinov | 2016-03-10 09:52
I mean the “force” or “strength” of the impact / collision. For example, I would apply more damage, if the objects colliding with more power. It’s hard for me to describe
Abgenullt | 2016-03-10 10:00
That’s exactly what I said I might answer a bit later though, since I’m a bit busy ATM.
Bojidar Marinov | 2016-03-10 11:05
I would like to know the answer to this as well. I tried making damage proportional to the difference in velocity between two objects, but this doesn’t take rotation into account, and is therefore useless for larger objects. I would manually take rotation into account, if only I could get the x,y of the collision…
You can calculate impact from RigidBody.linear_velocity, but beware that signal BodyEntered happen after contact/collision, so linear_velocity will drop based on how it collide. to trick this, make one buffed value for linear_velocity time after time using func _integrate_forces (state)