scene.deltaTime not defined on first frame

When using scene.deltaTime to manipulate objects, it appears it isn’t valid until after the first frame has been rendered.
Specifically, it is undefined.

This should instead default to 0 for the first frame so that any maths using the value doesn’t cause errors.

The documentation doesn’t state this and I had to deduce that this was the case: Scene | Babylon.js Documentation

Could you use engine.getDeltaTime() instead ?

1 Like

It looks like that’s accessible from scene nodes, so it should be fine for my use case.

But a scene can optionally render or not per frame, so technically there’s a disconnect?

This would only work if you import Animatable.ts as by default the animation system is not in use if you do not need to. Could you confirm if it works and we ll at least improve the doc ?

Confirmed that using engine.getDeltaTime() returns 0 for the first frame and doesn’t create an issue here.
Previously, I had to use the equivalent of delta = scene.deltaTime | 0 to avoid this issue.

I’m using Brython/JS directly so I didn’t have to perform any extra imports. I’m also not using the Animation system, at the moment just the SpritePackedManager.