# Wrong z position

**URL:** <https://forum.defold.com/t/wrong-z-position/77937>\
**Category:** Bugs\
**Created:** [August 31, 2024, 12:41pm UTC](https://forum.defold.com/t/wrong-z-position/77937 "2024-08-31T12:41:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [August 31, 2024, 12:41pm UTC](https://forum.defold.com/t/wrong-z-position/77937/1 "2024-08-31T12:41:40Z")

</div>

I have a strange issue with z position after a scale. Maybe I am missing something very basic here, but I would say that the z position of a child object is wrongly computed if the parent object has a scale. Let me explain a bit in details.

1. I have created a “Basic 3D project” from the template.
2. In the main collection I have added a child go to the “main” go and I have called it “TEST”
3. I have set the scale of TEST to 2.0, 2.0, 2.0 (uniform 2.0).
4. I have added 3 game objects to TEST, each with a model component with model the builtin cube; these go’s are “go\_0”, “go\_1” and “go\_2”.
5. I have set the position of these 3 go’s to be: 1.5, 0.0, 0.0 — 1.5, 15.0, 0.0 — 1.5, 1.5, 1.5 respectively
6. I have added some lines to main.script in order to print the world positions of these 3 go’s: and I see  
DEBUG:SCRIPT: vmath.vector3(3, 0, 0)  
DEBUG:SCRIPT: vmath.vector3(3, 3, 0)  
DEBUG:SCRIPT: vmath.vector3(3, 3, 1.5)

It seems to me that the z position of go\_2 should be 3.0 and not 1.5… It seems that the engine is not taking into consideration the scale of the parent object when it computes the z positions of the child objects.

Please note that, when I run the project, I can confirm that go\_2 is in a wrong position. But the scales of the objects are all fine. Also, in the editor the positions are all fine.

I am really surprised by this error. Let me say again, maybe I am missing something. It is a very basic setting and I am using a template project.

Version 1.9.2  
editor sha1: 8a5478f8b67306dcc6b3e6ebf33e3b3114e430fd  
engine sha1: 3251ca82359cf238a1074e383281e3126547d50b

---

<div class="post-metadata">

**Author:** ![Janey](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/janey/32/36448_2.png) [@Janey](https://forum.defold.com/u/Janey)\
**Post date:** [August 31, 2024, 3:05pm UTC](https://forum.defold.com/t/wrong-z-position/77937/2 "2024-08-31T15:05:50Z")

</div>

Yep, this is a known issue.

> [@Z coordinate scaling bug (Not a bug, but a feature)](https://forum.defold.com/t/z-coordinate-scaling-bug-not-a-bug-but-a-feature/34739):
>
> Looks like there is a bug when you specify Z coordinate inside a model and then scale the resulting game object. Scaling is not affected by the Z coordinate.

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [August 31, 2024, 3:26pm UTC](https://forum.defold.com/t/wrong-z-position/77937/3 "2024-08-31T15:26:22Z")

</div>

It does not seem the same bug to me. It seems that the world position is wrong, i.e. the engine computes wrong matrix multiplications when it composes the trasforms of objects.

I don’t understand how a 3D game can be developed with this kind of basic issue… really!

Please save linear algebra 🙂 @britzl @Mathias_Westerdahl

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [September 1, 2024, 1:18pm UTC](https://forum.defold.com/t/wrong-z-position/77937/4 "2024-09-01T13:18:19Z")

</div>

All right. The situation is a little better than I thought. I opened the .collection files as text and changed everywhere ‘scale\_along\_z: 0’ to ‘scale\_along\_z: 1’ and now it works.

Note, by the way, that it is not enough to set the option in the .collection file with the model component. This must be done for all files that include or create, with a collectionproxy, this file with the model component.

Furthermore, and this seems really weird to me, the editor does not take into consideration this option and always calculates position.z in the correct way (i.e. with ‘scale\_along\_z: 1’).

I love Defold, I have been using it with great satisfaction for years and I wish Defold every possible success. For all that I would say that there should at least be an option in game.project that, when activated, sets the value of scale\_along\_z to 1 by default in every new collection created.

Long Live Defold!

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [September 2, 2024, 6:41am UTC](https://forum.defold.com/t/wrong-z-position/77937/5 "2024-09-02T06:41:06Z")

</div>

Yes, we do not like that option either, and we have to come up with _something_ to unify the two code bases.  
As our 3D track progresses, we need to decide on how to do it. In short, we most likely don’t want the option to exist, and instead only have 1 mode, with proper transform calculations as the default.

In any case, I’m glad you figure it out!
