Jump to content

3rd Person Camera with offset [Solved]


Rehkitz
 Share

Recommended Posts

Hello,

I wanted to create a 3rd person camera that is similar to the game Fortnite. I created already one example where the player is always in the center, but many games have a little offset to the camera and is more pointing to the shoulder of the character.

I have no idea what math I have to use and all my attemps just changed the pivot point.

 

Here is my example:

https://www.babylonjs-playground.com/#JHB4AG#1

 

It would be cool if someone can explain me what I have to do so that the camera is pointing to the upper right corner of the cube, but the rotation is around the character.

Link to comment
Share on other sites

Thanks for the help, but I need a camera position offset, not a rotation offset. In this example the cemera is right behin the object, but I want the camera behind but slighty to the right. The pivot point should still be the charachter.

I want a camera like this (This is not my video, just an example for the camera I want): 

 

Link to comment
Share on other sites

Hiya R!  Sorry that I misunderstood.  Umm... I don't think the camera in the video... has its target/pivot set to character position.

From what I can tell, the camera target is an invisible mesh, parented to character, positioned up and right of character.

Let's have some fun, using that idea...

https://www.babylonjs-playground.com/#1CC7UC#19

Thoughts?

Essentially, this is simulating an arcFollowCamera.  Let's try one of those... without any camera .alpha spins.

https://www.babylonjs-playground.com/#1CC7UC#20

Wingnut not doing so well.  :) I will keep thinking/testing.  Others might have more ideas.

Link to comment
Share on other sites

  • 10 months later...

Hi,

i was looking also for a third person camera ( arcRotCam ) attached to a physic mesh and found this topic.

Instead that the mesh moves the cam, i wanted to inherit the movement from the mesh to the cam.

End result should be a vr camera which is attached to an object/mesh (car) that is moving. The cam should rotate with the mesh in curves and also allow to look around.

What I came up with and it worked:

renderloop(){

if(keydown){

   scene.activeCamera.target.x = parseFloat(targetMesh.position.x);

  scene.activeCamera.target.z = parseFloat(targetMesh.position.z);

   eulers = this.targetMesh.rotationQuaternion.toEulerAngles();

    scene.activeCamera.alpha = -parseFloat(eulers.y);

}

}

 

The problem now is that i constantly block/override the alpha/rotation of the camera so the users input e.g. on leftMouse down/or later on deviceoriantation has no effect anymore on rotating the camera on the y Axis/alpha. Does someone have an idea how to also add the users input values to that.

Thanks a lot

Link to comment
Share on other sites

  • 4 weeks later...

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