Search the Community
Showing results for tags 'look at'.
-
Hello, I've been adding features to my game, and came across a weirdness that I don't know how to explain! I've created the basis for my question here. There are a number of objects in the game scene, and I want the player to be able to choose one to look at. I am using the FreeCamera, since it suits my purposes. After adapting the TargetCamera.setTarget function to return the rotation vector of a camera without setting its target explicitly, I can now create an easing animation which gracefully orients the camera in that direction. The link above demonstrates this working in a loop which starts one animation, then on completion, selects a new random target, and starts the animation all over again. The problem is Line 45: camera.rotation.z = 0; Without this line, at the end of the animation, the camera.rotation (normally a Vector3 with x,y,z) becomes a Vector2 with x,y. This causes the screen to go black after the last frame of animation. Now, my two questions: 1. Why? It seems to me that dropping the last part of a Vector3 at the end of an animation is a bug, but my inexperience with BabylonJS makes me think there is probably a better explanation. 2. Is there a better way that I could animate a FreeCamera's orientation? Thanks for your time, and if this solves a problem for anyone, please enjoy the code Cheers, - Peter