How to make damage with an object only if it's impulsed by physics force?

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

Hi, i’m making a sport game, like a dodge ball game, i need help with the ball physics, how do i make it damage the player when it hits, depending on the impulse of the physics force?

:bust_in_silhouette: Reply From: bloodsign

RigidBody2D has a property called linear_velocity which returns a Vector of how fast your RigidBody2D object is moving.

Just use the Pythagorean formula if you want the c

var c =  sqrt((linear_velocity.x * linear_velocity.x) + (linear_velocity.y * linear_velocity.y))
		

use linear_velocity.length() is simpler.

corona_virus | 2021-12-18 21:27