-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Child entities don't inherit scene from parent, logs warning when killed #2419
Comments
@mattjennings Thanks for the issue! Definitely a bug, it should 100% have the scene attached that is an oversight. |
I was just about to raise something similar, so good timing! My suggestion was to improve the warning message to include the actor's name to help narrow down the warning when it does pop up. But a fix to the underlying issue would also be ace. Something like:
|
@chrisk-7777 this is a great idea, I think adding this context to the log will help a ton. |
Thanks for the fix! It's amazing the speed of development on this project |
Related #2419 (comment) ## Changes: - Update log message to be more helpful
Just a follow up to this one. I'm getting a strange issue, its somewhat related to the above - I started by calling So as an alternative, I tried https://codepen.io/chrisk7777/pen/gOeKOOy?editors=0010 Note how every second child is removed? Not all of them. This had me scratching my head, but after some digging, and I could be wrong, but I believe its because we're altering the array inside a loop: (sorry late night edit: @eonarheim if you prefer this as a new issue or simply a discussion post, let me know) |
@chrisk-7777 thanks for the follow up! I think we definitely have a couple bugs! These should be easy to fix quick, thanks for spotting! I can make a quick issue for these 👍 Bug 1: Doh! You're 100% right about the Bug 2: Child actors should definitely not be present in the parent |
Posted a PR 👍 #2454 |
Great, thanks for looking into it @eonarheim 🙌 Bug 1: Haha, yup I've been there. |
It seems the bug is still present when you add child actors to other actors, using
|
I haven't tested the above, but just confirming the extra let actor = new Actor()
let anotherActor = new Actor()
actor.addChild(anotherActor()) // <-- the extra () after anotherActor
anotherActor.kill() |
It appears that child entities do not inherit
this.scene
from its parent. I first noticed this when killing an actor with children and getting the following warning:After digging into it I noticed it was the child entity logging the warning, as
this.scene
was null here:Excalibur/src/engine/Actor.ts
Lines 795 to 804 in 730d621
If the child entities aren't truly killed it's possible this might be a memory leak, but I haven't dug much further.
Steps to Reproduce
repro: https://codesandbox.io/s/exaclibur-child-entities-bug-5r0w3e?file=/src/index.js
actor.addChild()
Expected Result
Children should inherit scene from parent and no warning log should occur when killed
Actual Result
Children do not inherit scene and a warning is logged when parent is killed
Environment
Current Workaround
None
The text was updated successfully, but these errors were encountered: