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

2D child Z grows without bounds #125

Closed
Pierre-Borges opened this issue Aug 18, 2023 · 0 comments · Fixed by #134
Closed

2D child Z grows without bounds #125

Pierre-Borges opened this issue Aug 18, 2023 · 0 comments · Fixed by #134
Labels
C-Bug Something isn't working

Comments

@Pierre-Borges
Copy link

I made an entity with a position that has a child which also has a position. Both of them have a nonzero z component for draw ordering. That caused the z component of the transform to go off like crazy.

I think this is caused by position_to_transform taking the z coordinate of the child's original transform and treating it as a global transform.

                let new_transform = GlobalTransform::from(
                    Transform::from_translation(pos.as_f32().extend(transform.translation.z))
                        .with_rotation(Quaternion::from(*rot).as_f32()),
                )
                .reparented_to(&GlobalTransform::from(parent_transform));

I changed this to

                let new_transform = GlobalTransform::from(
                    Transform::from_translation(pos.as_f32().extend(transform.translation.z + parent_transform.translation.z))
                        .with_rotation(Quaternion::from(*rot).as_f32()),
                )
                .reparented_to(&GlobalTransform::from(parent_transform));

but I don't know if that still works if the parent is scaled. Maybe it would be best to just set it after doing the GlobalTransform::from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants