@TwistedTwigleg said:
For my project, using _physics_process
works fine because I am just adding and removing forces using the add_force
and apply_impulse
functions, rather than directly modifying the velocity vectors. I just slapped the code in and used _physics_process
for testing purposes.
I knew the code was for stopping the ball from moving when velocity is low, but the project I am using has linear damping and angular damping on the RigidBody, which slows the RigidBody. This would make it hard to tell how the code was working in the project, so I opted for triggering the result using Input instead.
First of all, Thank you a lot for taking your time trying to figure out this.
I found out why I think it doesn't stop.
_integrate_forces
is called when there is physics processing, in my case movement. So, I was playing around and using your example I found that setting the Velocity to Zero doesn't actually make the Velocity Zero instantly, visually yes but in the Physics engine, No.
Here is whats going on:
LinearVelocity.Lenght: 0.10027980000000000000
LinearVelocity.Lenght: 0.09946802000000000000
19198 --> Emit Signal Stopped
LinearVelocity.Lenght: 0.00000286102300000000
21217 --> Emit Signal Stopped
LinearVelocity.Lenght: 0.00000286102300000000
... Many more here
21217 --> Emit Signal Stopped
LinearVelocity.Lenght: 0.00000000000000000000
As you can see above it drops to a negligibly small number BUT the _integrated_forces
is still being called until it finally drops to Zero.
So I can 'safely' assume that if the Velocity length is under 0.0001 the ball has stooped and work accordingly.
Thanks