Which is the best way to keep a Physics Actor frozen / stopped without disabling physics?

Hi, I have moving physics actors that I want to freeze, stop or pause at a certain point. Which is the best way to do so without disabling SimulatPhysics? If I do so I meet undesired go-through behaviours… By the way, Put Rigid Body To Sleep doesn’t work on my actors’ physics static meshes.

I am new to this but have you tried setting actor transform to current location. I believe this would kill and speed it had built up. However I have not tried it and it may not work. Let me know how you solve this as I wouldn’t mind figuring it out either.

Hi, thanks for the suggestion, but Set Actor Transform or Location for the simulated actors would only work for the frozen sort of effect if I did it repeteadly, but that is a bad solution in my opinion (setting location to the frozen location on every Tick is bad because the actors moves a bit even with best framerate; and doing it repeteadly at computation time, so faster than Tick, at first with a while loop would give an infinite loop warning/error, and with a bit of a workaround to avoid that, it would still be a bad solution in my opinion, specially with lots of physics actors in action, as performance would go down in quality).

What would be great would be to be able to set the actor’s gravity to 0, but I haven’t found that possibility. Set Enable Gravity seems to have no effect while simulating…

If you have other suggestions they would be very welcomed!

1 Like

I’m looking for a solution to a similar issue but stumbled across this in doing so. I’ve used a physics constraint velocity drive which works pretty well.

This is a problem for me now - I don’t want to pause through the controllor (at least I think I don’t) because I would like to animate objects during pause. However I do want a subset of objects to 1) not move and 2) Not respond to any collisions (i.e. behave fixed) and 3) Not accumulate any forces and 4) maintain their current velocity and overlaps with other paused objects etc when I unpause them.

The current problem I’m facing is that forces seem to accumulate while they are paused.

Try setting the object to sleep then reawaken the rigid body whend desired

You can stop the actor movement applying this formula (still being affected by gravity)

meshComponent->AddImpulse(meshComponent->GetPhysicsLinearVelocity() x (meshComponent->GetMass() x -1));

This is what worked for me, thank you!

This works pretty well, the issue I had was that even though it stopped moving, it was still spinning. I even tried Adding angular impulse but that did not help. Ultimately, Physics Constraint saved the day for me.

One of the simplest approaches is to try smth like this

  1. call OnDestroyPhysicsState() to destroy PhysX Actor in PhysScene

  2. call BodyInstance = FBodyInstance() to get new BodyInstance (PhysScene is working with BodyInstance reference as key for mapping)

  3. call all lines in your Costructor that are modifying BoduInstance (for example you can etract it to method)

  4. call OnCreatePhysicsState() to add new PhysX Actor corresponding to newly created BodyInstance to PhysScene

Another approach is to override PhysScene class and use PhysSubSteppers queue, but it seems too vast as for the changes just for solving such simple problem as stopping body from moving at once. Honestly, this method is far more precise (just see that AddForce and AddTorque works similar using FPhysTarget class)

I know it’s bit late but may I ask what was your setting for physics constraint velocity drive?