Jump to content

ArcRotateCamera position.y do not work


Recommended Posts

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.


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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.)


Thank you Deltakosh

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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));


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...