Dad72 Posted September 10, 2018 Share Posted September 10, 2018 I wanted to change the value y of the position of the rotating camera, but that has no effect. Only setPosition () works. only if I use this, it creates a problem for the animation of my character that prevents me from directing it to the right or to the left. By that I modify it in a loop to know the orientation of the camera and rotate the character, but I can not change the position Y. http://www.babylonjs-playground.com/#UCFKM#102 What I was looking for was, for example, if my character climbs stairs, the position of the camera also goes up on the Y axis in ways to follow the character. because currently the camera remains at the bottom of the stairs. Quote Link to comment Share on other sites More sharing options...
Guest Posted September 10, 2018 Share Posted September 10, 2018 This is because the ArcRotateCamera does not use position internally (hence that's why you need to call setPosition). When you call setPosition it will transform the position into alpha, beta and radius which are the properties used by the camera. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 10, 2018 Author Share Posted September 10, 2018 Yes, but as I was explaining, this prevents me from creating the movements of the camera if I put setPosition in a loop to verify that my character is being moved. So how to change this position Y only to prevent the camera remains at the foot of a staircase? Quote Link to comment Share on other sites More sharing options...
Guest Posted September 10, 2018 Share Posted September 10, 2018 can you repro what you try in the PG? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 10, 2018 Author Share Posted September 10, 2018 Ok, I'll try to create one tomorrow. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 11, 2018 Author Share Posted September 11, 2018 Ok, I did a PG to show how I do. Try to climb the stairs (Z key on the QWERTY keyboard or W I think) You can see that the camera does not come up at the same time as the character goes up. And I wanted the camera to follow, but I can not change the Y axis only on a rotating camera (and I need a rotating camera to be in orbit around the character.) http://www.babylonjs-playground.com/#QY1WYT#21 Thank you Deltakosh Quote Link to comment Share on other sites More sharing options...
Guest Posted September 11, 2018 Share Posted September 11, 2018 Well it works for me:)_ http://www.babylonjs-playground.com/#QY1WYT#22 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 11, 2018 Author Share Posted September 11, 2018 Ok, I see, I did not put my setPosition in the right place. Thank you Deltakosh for your eye GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 11, 2018 Author Share Posted September 11, 2018 Arf, sorry Dk, in fact it works only in a straight line. I can not orient the character right or left while walking as my first PG. He always goes all on the Z axis The setPosition on the X and Z axis blocks the movement of my character on the right to the left. I would like to change only the Y axis, the X and Z axis should not be changed for the position Try to climb the stairs and make a half turn to go down. It's not possible, it continues to rise. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 11, 2018 Author Share Posted September 11, 2018 I solved the problem: but i have a strange problem, if i use setTarget, it does not work well. if i use the same value as setTarget but doing camera.target.x ... it works better. I do not know if it's normal? http://www.babylonjs-playground.com/#QY1WYT#24 Quote Link to comment Share on other sites More sharing options...
Guest Posted September 11, 2018 Share Posted September 11, 2018 I see that you are using camera.target directly. For an arcrotatecamera you have to use setTarget. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 11, 2018 Author Share Posted September 11, 2018 This does not work properly setTarget. IF I'm using camera.target directly, this has solved my problem. Maybe there is a problem with setTarget Work good this.cameraPlayer.target.x = this.actor.position.x; this.cameraPlayer.target.z = this.actor.position.z; this.cameraPlayer.target.y = this.actor.position.y+1.7; Do not work this.cameraPlayer.setTarget(new BABYLON.Vector3(this.actor.position.x, (this.actor.position.y + 1.7), this.actor.position.z)); http://www.babylonjs-playground.com/#QY1WYT#24 Quote Link to comment Share on other sites More sharing options...
Guest Posted September 11, 2018 Share Posted September 11, 2018 Ok I understand why. This is because the setTarget will keep the current position and then move everything else (and thus can increase the radius) so what you are doing is fine! good job Dad72 1 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.