![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | 99week |
My project uses a RigidBody with a sphere and I want to set the max speed, the RigidBody can go.
rigidbody.linear_velocity.length()
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | 99week |
My project uses a RigidBody with a sphere and I want to set the max speed, the RigidBody can go.
rigidbody.linear_velocity.length()
![]() |
Reply From: | klaas |
Hi.
For that you have to integrate a _integrate_forces ( PhysicsDirectBodyState state ) function to your RigidBody. Then you have to modify the PhysicsDirectBodyState.linear_velocity to limit the speed. Like so … (did not test)
var len = min(max_speed, state.linear_velocity.length())
state.linear_velocity = state.linear_velocity.normalize() * len