BabylonJS / Babylon.js

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.
http://www.babylonjs.com
Apache License 2.0
22.99k stars 3.41k forks source link

updating globalPosition even when Camera is not the active camera #5496

Closed Nodragem closed 5 years ago

Nodragem commented 5 years ago

Hello,

I am making a game where you can switch between a top down view and a first person shooter view (FPS) with an animation in between. Note that I use two different cameras, and the FPS camera is attached to a mesh representing the player. Hence, when I make the animation from FPS to top-down view, I am animating the top-down camera.

What I noticed is that the FPS camera does not update its globalPosition when I move my player from the top-down view. In other words, the first person camera does not update its globalPosition when it is not active.

Feature request

deltakosh commented 5 years ago

Same comment. Please use forum for questions like this one. We try to keep the repo as cleaner as possible to track validated work only. Also we try to get only one source of knowledge for people to search for when they have a question

You can force your camera to update its global position by calling camera.getViewMatrix(true). All potentially expensive operations (like updating matrices or global info) are done on a "when required only" basis.

Nodragem commented 5 years ago

Ok I agree, that one should have been in the forum. But it looked like a dead end yesterday.

Thank you very much to give me the solution anyway; that saves my week. I think I may actually open a thread on the forum to copy paste your answer

Note that I do use the forum most of the time :)