Physics Object Sleeps Too Late

Hi .I have a door based on physics constraint. I want to check if it is open or shut(closed) based on it’s rotation when it stops movement to be able to play sound of slamming(close) sound. I am using OnComponentSleep node but physics body sleeps ~1 second later than it stops and makes it impossible to play sound as it closes. I tried to do same thing manually by checking velocity of it each frame like this:

Logically I shouldn’t get velocity 0.0 printed because True should be executed but for some reason it prints 0.0 for ~1 second (I get 10-15 prints of 0.0) and then branch executes True.
Please let me now if there is a better way of getting notified when physics object stops except for Hit events. Thanks.
Edit: I have tried using sensitive and custom sleep family options

Hi Nicat,

I tested this by using this setup and it seems to work fairly well, although I don’t have anything stopping the door besides the player.

If it doesn’t work for you, upload your exact setup in a small test project and I will see if I can help you find a solution that works better for you.

I changed tolerance to 0.0 (I am greedy I know) and thats when it happened. Even with default tolerance some times I get 0 printed out.

Also, did you try OnComponentSleep node?

Here is test project file:
link text

My main concern is sleep node. See how late it prints after door closes.

I think sleep node has the same problem as 0.0 tolerance. Sleep event fires exactly same time as 0.0 prints stop. If I couldn’t explain well just try setting tolerance to 0.0 and see how Zzzzzz prints exactly same time 0.0s stop printing.

That isn’t working like you would expect because of the way that physics objects are put to sleep in the engine. When a physics object, lets say a box, is knocked around the level; when it stops the editor will wait a fraction of a second before putting it to sleep. This is to allow the object to settle or finish any minor movements. It’s more obvious with a free moving physics object rather than a constrained door.

I would suggest implementing this with a version similar to my setup above. You could even further the setup to something ‘Amnesia-style’ by comparing a set location/rotation (closed position) to the velocity. That way if the door is moving slowly, you could play a softer close sound or no sound at all.