I set a mesh object to start as asleep and want it to wake 5 seconds after.
How can I set this?
Hi, any suggestion? I read this and seems that it can only be woken by collision - Physics Core — Omniverse Create documentation
I want to make it such that after 60 frames the object wakes up and start moving.
Hello @qazs! I reached out to the development team for more information regarding this. I will post back when I have more information!
Hi @qazs. I am not sure I understand what you are trying to do. Could you please elaborate on what the object should do after the five seconds asleep? Is it a kinematic rigid body or a dynamic rigid body, and how should it move after sleep?
Otherwise the documentation is accurate, wake up happens if you apply an external force or there is a contact, so the object participates in the simulation again (sleeping saves computational resources).
I have an object (dynamic rigid body with collider preset) with x-velocity set to a value and want it to be still on start and only start moving along the x-axis after 5 seconds. I can freeze it using start as asleep, but how can I unfreeze it without interacting with other objects? Without starting as asleep, it starts moving immediately when hitting playback. Or is there any other way to achieve this? In other words it’s ‘Stay still for 5 seconds, then start moving’
Is you object a rigid body, i.e. should it move freely under the influence of gravity and collisions after 5 seconds, starting with the initial velocity you set?
If not, you can make it kinematic and use a time-sampled velocity.
Yes it should move freely after the 5 seconds according to the physics simulation. I can’t use kinematic because otherwise it won’t be interacting with other objects. I tried with time-sampled editor but there’s no velocity settings in it.
If you can use Python scripting, there is a PhysX Python binding called
apply_force_at_pos that you can use to push / set the velocity of a rigid body. Have a look at
Help > Physics Scripting Manual.
If you need to perform the velocity change purely through USD, I would have to find out if/how this is possible.
I tried with this code but no effect. Applying velocity works, but still I can’t get to set velocity at a certain time
cubePath = '/World/Cube' stage = omni.usd.get_context().get_stage() cubePrim = stage.GetPrimAtPath(cubePath) linVelocity = Gf.Vec3f(0, 0, 0) rigidBodyAPI = UsdPhysics.RigidBodyAPI.Apply(cubePrim) rigidBodyAPI.CreateVelocityAttr().Set(linVelocity) forceSize = 1 * 10000.0 force = carb.Float3(1000 * forceSize, 0, 0) get_physx_interface().apply_force_at_pos(str(cubePath), force, (1,0,0))
The effect I want is a ball shooting out from a catapult after 5 seconds. How can I do this without using animation?
For timing, I would suggest using a physics step callback, or the stage update callback.
You can find an example of using the physics callback as a timer in the fixed tendon snippet, see screenshot. You can just adapt the snippet code, or write your own extension to run your own code. You should be able to run something similar from the script editor, but it’ll be not as straightforward to manage the update event subscriptions.
As for the applying a force, I created a cube with mass 1 on a stage and then run this when the sim is running (manually from the script editor) and it works:
import carb import omni.physx target_vel = 100.0 mass = 1.0 dt = 1.0 / 60.0 force = mass * target_vel / dt omni.physx.get_physx_interface().apply_force_at_pos( "/World/Cube", carb.Float3(force, 0.0, 0.0), (0, 0, 0), "Force")
cube_stage.usd (2.5 KB)
Thanks, your code example is great. I’ll do some research on the stage update callback.