Cannot always apply rotation from mesh to mesh (spawn points)

Hi everyone

I have been trying to implement level spawn points. But I got stuck getting rotations right. In the playground the elf should look in the direction the respective cone tip points at.

Please see here (https://playground.babylonjs.com/#88CB6A#116). There is an elfSpawner() function at line 56.

If you hit the spawn button, see how the elf’s rotation is off 180° for some cones? I do not get that: why only some and not all?

Best wishes
Joe

@bghgary might know a trick ?

You are applying the transforms at the wrong level to copy them: https://playground.babylonjs.com/#88CB6A#117

Basically you need to not account for the root transform (assuming it is identical) in both cases.

1 Like

Thanks @sebavan! Works :slightly_smiling_face:

Is it true that this is a GLTF/coordinate system issue? It kind of through me off that only half of the rotations worked.

And if so, is it a good general solution to better no operate on the GLFT root nodes? (e.g. in order to avoid issue like here)**

**Was thinking about sth like this: https://playground.babylonjs.com/#88CB6A#118
But doesnt work in my local playground :frowning:

Here is an alternative solution: https://playground.babylonjs.com/#88CB6A#119

It uses mesh.lookAt in conjunction with the spawn point’s forward vector and avoids using the spawn point’s rotationQuaternion. In my local playground, I just could not get it to work otherwise.

Not really. Basically Babylon and GLTF do not work in the same handedness so we have a special root node dealing with it.

You could also force scene.useRightHandedSystem to not have the extra root.