stormwarestudios Posted October 10, 2016 Share Posted October 10, 2016 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 10, 2016 Share Posted October 10, 2016 Hello and welcome! The problem is that rotation is computed by the camera using its target property. So here you are animating something that the camera also tries to update So instead I suggest animating camera's target instead Quote Link to comment Share on other sites More sharing options...
stormwarestudios Posted October 10, 2016 Author Share Posted October 10, 2016 Hello! Thanks, Deltakosh. That makes sense to me. I will look in to your suggestion. Thanks again! - Peter Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 10, 2016 Share Posted October 10, 2016 Please keep us posted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.