linear_velocity not reaching (0,0) with linear damping

Godot Version

4.5.1 stable

Question

Hello everyone,

I am currently fiddling around with RigidBody2Ds and was wondering about a specific “problem” I’ve encountered. I am running the following script on a RigidBody2D with linear and angular damp set to 1.

extends RigidBody2D

var thrust
var i: int

func get_thrust() -> void:
    thrust = -(global_transform.x) * 20
    

func _physics_process(delta: float) -> void:
        get_thrust()
        
        if i < 100:
            apply_central_force(thrust)
            i += 1 
            
        print(linear_velocity)

After i reaches 100 and the acceleration (by applying a central force) stopped, I would expect the linear_velocity of the RigidBody2D to reach (0, 0). It decreases until it reaches (-1.041393, -0.485609). Then the deceleration / damping stops and the linear_velocity is not further decreasing.

I was wondering if anyone could explain this behaviour. I tried digging through the Documentation and engine code but couldn’t figure out why this might be happening.

Thanks!

Probably your rigid body went to sleep. Add another print statement to your function to check that:

        print(linear_velocity)
        print(sleeping)

When the body is sleeping, it doesn’t recalculate any of its physics properties anymore.

1 Like