TomaszFurca Posted October 5, 2018 Share Posted October 5, 2018 Today i working with cameras in my game. I am confused about correct solution to do that as best as possible, generally in performance. I have two camera first for GUI, second for objects render with post processing. For every position change of my player i must update position for two cameras like that: const camera = this.game.getScene().getCameraByName('gameCamera'); const guiCamera = this.game.getScene().getCameraByName('GUICamera'); const newPosition = this.meshForMove.position.clone(); camera.position = newPosition.clone(); camera.position.y = 30; camera.position.z -= 22; camera.position.x -= 22; guiCamera.position = newPosition.clone(); guiCamera.position.y = 30; guiCamera.position.z -= 22; guiCamera.position.x -= 22; I must update twice cameras, because onPointerDown event return PickPoint from GUICamera, because it is registered as second active camera. I use that code in function in registerBeforeRender, when player moves. Also i tried with box, which was children of my character mesh and parent of my cameras, but when my character change rotation, then cameras lost correct position. I don't know how keep correct position using parent system. Maybe someone have idea how do that better? Thanks Tom Quote Link to comment Share on other sites More sharing options...
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.