+1 vote

I'm using a custom time scale variable and an Area3D to recreate the time stop power in Quantum Break, it's working with kinematic bodies as they move using move and slide, however such function doesn't exist in rigidbodies...

Is there a way to change and store the velocity of a rigidbody and reapply after the effect ends?

Godot version 3.4.4
in Engine by (15 points)

I think this would be quite complex, I believe you would need to change the applied forces on the rigid body and even then you may find it spins at a normal speed so you might have to play with the torque etc.

The documentation is here if it helps

https://docs.godotengine.org/en/stable/classes/class_rigidbody2d.html

I have never tried it before so somebody else may have a bit more experience with what you are trying to do.

Yeah after messing around i found that this is quite complex, maybe i just play with both the damp values and reaply the speed after.

Have you considered using kinematic bodies? I dont know exactly what your game is but it would be easier with those. You could use area 2d's with a function attached to the body entered signal to control their actions when they hit the ground or another object but this could end up being more complex in other ways depending on what your game is exactly.

Using kinematic bodies could be easier to implement and control, if i did know how to make them interact with each other pushing and rotating other instead of being static.

Them multiplying their move speed, animation rate and timers with a variable would create the illusion.

1 Answer

0 votes

Function integrate_forces() of rigid bodies uses stateargument under the hood, You can access it from within this function. It contains information about current movement whereabouts and a time flow of physicsserver.
for example :

func integrate_forces(state) :
         var speed = state.linear_velocity.length()
         var time = state.step

https://docs.godotengine.org/en/stable/classes/class_physics2ddirectbodystate.html#class-physics2ddirectbodystate

I guess You can try to read current speed and experiment with adapting damp, mass or friction when in area. Perhaps there are easier ways. Are You moving your bodies with applyforces or applyimpulses ?

by (7,305 points)

Im using rigidbodies for moving around simple boxes and throwing balls around, maybe when the bodies enter the area I store their speed and lerp the damp value to a higher number, them revert the damp and apply the impulse.

I could use kinematics for this but i don't know how to make them push each other.

So You are using passive rigid movement, this is going to be hard :)
I wonder if it is possible to override state. Maybe You could try something like multiplying state.step by 0.5 when collision is occuring

The physics step is a getter only property so it's not possible to change it's value like with engine.time_scale, instead multiplying linear and angular speed by the slow factor variable could do the trick, the problem is to make it travel the same distance and path.

After some experiments I managed to slow down the speed by lowering gravity and increasing the mass, it's like the body is falling in half speed but manteining his path, however this only works with vertical speed because increasing drag changes the distance the object travels...

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.