So, I’ve implemented the temporary solution. I’ve found that native extensions can subscribe on the pre-render callback, and I’ve used that for the late update logic. The only downside is that the callback isn’t called if the application is iconified.
How to use:
- Add Scene3D as a dependency:
https://github.com/indiesoftby/defold-scene3d/archive/refs/heads/main.zip
. - Call
scene3d.prerender_register
/scene3d.prerender_unregister
to subscribe (unsubscribe) for that pre-render event:
-- This update will happen after game objects have been moved by the physics engine
-- Messages from that code are dispatched next frame!
local function late_update(self)
-- Get position/rotation, update position/rotation, etc.
end
function init(self)
local priority = 1 -- It's an optional parameter. All pre-render callbacks are sorted by priority (ascending: 1, 2, 10, 50, and so on.) and called one by one.
self.prerender_id = scene3d.prerender_register(late_update, priority)
end
function final(self)
if self.prerender_id then
scene3d.prerender_unregister(self.prerender_id)
end
end