Skip to content
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 entity should inherit transform.coordPlane of parent #2933

Closed
mattjennings opened this issue Feb 16, 2024 · 1 comment · Fixed by #2936
Closed

Child entity should inherit transform.coordPlane of parent #2933

mattjennings opened this issue Feb 16, 2024 · 1 comment · Fixed by #2936
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior

Comments

@mattjennings
Copy link
Contributor

I think a child entity should inherit the coordPlane of its parent's transform.

Consider having a ScreenElement with children - currently, its children do not follow along with it (at least, not properly). If I set the coordPlane of the children to ex.CoordPlane.Screen, they do.

Steps to Reproduce

export default class Level1 extends ex.Scene {
  onInitialize() {
    const player = new ex.Actor({
      x: 100,
      y: 100,
      width: 100,
      height: 100,
      color: ex.Color.Yellow,
      vel: ex.vec(50, 0),
    })
    this.add(player)

    this.camera.strategy.lockToActor(player)

    const screenEl = new ex.ScreenElement({
      width: 100,
      height: 100,
      color: ex.Color.Red,
    })

    this.add(screenEl)

    screenEl.addChild(
      new ex.Label({
        text: 'hello',
        color: ex.Color.White,
        font: new ex.Font({
          size: 32,
        }),
      }),
    )
  }
}
CleanShot.2024-02-16.at.16.15.24.mp4

Expected Result

It's a bit hard to tell in the clip, but "hello" should be staying in position as a child of the red box screen element.

Actual Result

"hello" coordPlane is to the world instead of the Screen, so it moves off the camera.

Environment

  • Excalibur versions: 0.28.7

Current Workaround

Manually setting the child's coordPlane to ex.CoordPlane.Screen

@mattjennings mattjennings changed the title Child entity should inherit transform.coordPlane Child entity should inherit transform.coordPlane of parent Feb 16, 2024
@eonarheim
Copy link
Member

@mattjennings I agree, I think someone else ran into this and it produces unexpected results.

Going to label this a bug

@eonarheim eonarheim added the bug This issue describes undesirable, incorrect, or unexpected behavior label Feb 17, 2024
eonarheim added a commit that referenced this issue Feb 17, 2024
Closes #2933

This PR forces children to inherit their parent's coordinate plane, it will always be the coordinate plane of the top most parent.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants