diff --git a/Extensions/3D/Model3DRuntimeObject.ts b/Extensions/3D/Model3DRuntimeObject.ts index 1da6d637a8a9..5549284d6530 100644 --- a/Extensions/3D/Model3DRuntimeObject.ts +++ b/Extensions/3D/Model3DRuntimeObject.ts @@ -113,6 +113,10 @@ namespace gdjs { ); } + if (this.isNeedingLifecycleFunctions()) { + this.getLifecycleSleepState().wakeUp(); + } + // *ALWAYS* call `this.onCreated()` at the very end of your object constructor. this.onCreated(); } @@ -194,6 +198,10 @@ namespace gdjs { } } + isNeedingLifecycleFunctions(): boolean { + return super.isNeedingLifecycleFunctions() || this._animations.length > 0; + } + update(instanceContainer: gdjs.RuntimeInstanceContainer): void { const elapsedTime = this.getElapsedTime() / 1000; this._renderer.updateAnimation(elapsedTime * this._animationSpeedScale); diff --git a/Extensions/TileMap/tilemapruntimeobject.ts b/Extensions/TileMap/tilemapruntimeobject.ts index e1cad78175d1..3857468e6c87 100644 --- a/Extensions/TileMap/tilemapruntimeobject.ts +++ b/Extensions/TileMap/tilemapruntimeobject.ts @@ -39,6 +39,10 @@ namespace gdjs { ); this._updateTileMap(); + if (this.isNeedingLifecycleFunctions()) { + this.getLifecycleSleepState().wakeUp(); + } + // *ALWAYS* call `this.onCreated()` at the very end of your object constructor. this.onCreated(); } diff --git a/GDJS/Runtime/runtimeobject.ts b/GDJS/Runtime/runtimeobject.ts index 44a0786a45b5..7af0fcf85893 100644 --- a/GDJS/Runtime/runtimeobject.ts +++ b/GDJS/Runtime/runtimeobject.ts @@ -238,12 +238,11 @@ namespace gdjs { ); this._totalForce = new gdjs.Force(0, 0, 0); this._behaviorsTable = new Hashtable(); + this._timers = new Hashtable(); this._lifecycleSleepState = new gdjs.ObjectSleepState( this, () => this.isNeedingLifecycleFunctions(), - this.isNeedingLifecycleFunctions() - ? gdjs.ObjectSleepState.State.AWake - : gdjs.ObjectSleepState.State.ASleep + gdjs.ObjectSleepState.State.ASleep ); this._rtreeAABB = { source: this, @@ -276,7 +275,6 @@ namespace gdjs { } this._behaviorsTable.put(autoData.name, behavior); } - this._timers = new Hashtable(); } //Common members functions related to the object and its runtimeScene :