Jump to content

How to rotate mesh with ArcCamera's alpha?


kevzettler
 Share

Recommended Posts

I have an ArcCamera with a root object as it's target. I'm going for a 3rd person or "over the shoulder camera". I want the root to rotate on the y axis when the ArcCamera moves on the alpha axis. I'm currently doing something like:

Quote

root.rotation.y =  -1 * camera.alpha;

It seems like the alpha is at a lower magnitude than what the rotation vector expects. I can rotate the camera like 3 times around the root before it rotates completely 

Link to comment
Share on other sites

I have looked at ArcFollowCamera it dosen't seem to be working for though. Once attached to a target to follow I cannot control it. I setup a playground here http://www.babylonjs-playground.com/#4FC2X#0

Also to get the desired effect I want, I would still have to rotate the target mesh based on the ArcFollowCameras alpha.

Link to comment
Share on other sites

@Deltakosh I'm having a hard time reproducing my setup in the playground environment. Playground is using v2.6-alpha I'm not on the same version. Actually I'm not sure what version I'm using is there a value I can check? Even so seems like coordinates are different between the two environments.

Here's my best attempt at reproducing http://www.babylonjs-playground.com/#GVPCK#4

Here's a better example on my production environment http://localhost:8000/robotbones/attempts/babylon/babylon-bones-qubicle-CEWBS/

Essentially I want the character to face the direction the camera is facing on rotate. I thought I could maybe use the alpha from the rotateCamera but maybe I can take the a direction vector from the character to traget and apply that to the character instead.



 

Link to comment
Share on other sites

thanks @Deltakosh

I was able to get the effect I want by doing

focus = arcCamera.getFrontPosition(100);
focus.y = 0;
focus.multiplyInPlace(negativeVector);
mesh.lookAt(focus);

How do I move the camera towards that direction? I'm currently moving the mesh with mesh.translate when keys are down. I want to do the same movement with the camera. Seeing the camera dosen't have a translate method

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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