playcanvas / playcanvas/engine

Disabling in `initialize` while a template is being instantiated does not correctly disable nested elements

Open
#5,382 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Description

When spawning a template, if any script inside the template disables the entity it is attached to immediately in initialize, then any nested elements to that entity are not disabled correctly. This leads to a broken enabled state, where children of the disabled entity are still enabled in the hierarchy.

Here is a link to a very simple project that reproduces this bug:
https://playcanvas.com/editor/project/1088612

I've reproduced the bug in both the Brave and Firefox browsers.

Steps to Reproduce
  1. Open the project in the editor. Observe that the TemplateSpawner will spawn a template when initialized. This template includes multiple children that have scripts attached that will disable themselves in initialize.
  2. Run the project.
  3. The green box dissapears correctly. The red box does not dissapear like it is supposed to.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction project and trace template instantiation, the TemplateSpawner, and scripts that disable their entities in initialize. Confirm the enabled-state behavior for nested elements, then verify that children of an entity disabled during initialization are also disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.