Jump to content

Physics events not enabled for spawned objects until cell reload


0Drew

Recommended Posts

If you spawn an object at runtime, whether it's through Papyrus' ObjectReference.PlaceAtMe or CommonLib's PlaceObjectAtMe, it won't receive physics events like onTriggerEnter until the cell is reloaded. The 3D model is there & non-physics events like OnInit() and OnUpdate() work fine. tl;dr the fix is to call Disable() Enable() on the object which will immediately fix the physics events without requiring a cell reload, but I will include my investigation results that go into more detail below.

 

1. If you print out the object's Disabled & InitiallyDisabled properties, they will both be false. So the object isn't actually disabled, and Enable() just forces the engine to update whatever didn't get the memo before

2. This does not happen if the same object is manually placed into the cell with the Creation Kit and saved to an esp. Physics events on objects spawned of that type in that cell will work immediately without cell reloading

3. This does not happen when using the console's placeatme command, so I suspect it is calling Enable() or some other update function on placed objects

4. Spawning the objects in different game events (OnCellLoad, OnCellAttach, OnLoad, OnInit) does not make a difference

Based on this, I'd guess that the object is actually enabled, but whatever Bethesda uses for physics events runs before Papyrus scripts on cell load and keeps track of a list of which base form IDs are eligible to receive physics events. Placing the object in the cell in the esp ensures it is in that list of valid base form IDs from the beginning, and enabling an object mid-gameplay (a common use case for Bethesda) seems to have a special case to update this list of valid base form IDs.

Edited by 0Drew
Link to comment
Share on other sites

  • 5 weeks later...

I seem to remember physics effects may only be seen on certain newly created objects if you give them a 'knock' first - so that might also be an alternative if disablenowait()/enablenowait() is inconvenient. A zero magnitude impulse using ApplyHavokImpulse should do the trick.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...