How can I know what direction a mesh facing? and if the mesh and the camera are facing the same direction?
If you consider that by default the mesh is facing (0,0,1) then finding the current direction is simply about transforming (0,0,1) by mesh.getWorldMatrix()
For the camera you should be able to use camera.forwardDirection (if my memory serves as I’m on my phone)
1 Like
I think camera.getDirection(Vector3.Forward() is what you mean, right?
Can you give me more detail about what you mean here? “finding the current direction is simply about transforming (0,0,1) by mesh.getWorldMatrix()”? I think mesh.getWorldMatrix() returns matrix? Sorry, just new to babylon if it’s an easy question
Yes
It is not really babylon but more matrix math:
for your mesh:
var direction = BABYLON.Vector3.TransformNormal(new BABYLON.Vector3(0, 0, 1), mesh.getWorldMatrix());