Mesh lookAt Not Working If the Mesh is Parented

HI newbie here. I created a box and put box.lookAt( my character position). It works fine I put it in the sceneRegisterBeforeRender function so it always follows my character wherever I go. However, If I put the box parent to another player the box.lookAt() is still working but not looking at me and it looks on a different location. I hope someone knows the trick to this I think I need to make the box look at in the Global Location but I dont know how

Could you setup a minimal repro in the Playground so that it’s easier for us to see what’s going on and try to find a solution?

You can use correction parameter of lookAt()-function, to take parent rotation into account:

I think you have to correct lookAt by invert rotation of your parent.

Also, there is a space parameter to the lookAt function, so you can try to use Space.WORLD as Space.LOCAL is the default value.

1 Like

It’s the third topic of yours I have to ask for a playground, it would make us able to understand your problem and answer your question much faster.

1 Like

just wanted to jump in here and say thanks for the space suggestion. this worked like a charm

mesh.lookAt(new Vector3(1,1,1), 0, 0, 0, Space.WORLD);
1 Like