Wrong z position

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

1 Like

Yep, this is a known issue.

1 Like

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 :slight_smile: @britzl @Mathias_Westerdahl

2 Likes

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!

2 Likes

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!

2 Likes