Rehkitz Posted June 24, 2018 Share Posted June 24, 2018 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. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 25, 2018 Share Posted June 25, 2018 Hi Rehkitz, welcome to the forum. BabylonJS has a "Follow Camera" that works pretty nice. https://www.babylonjs-playground.com/#1CC7UC#15 Adjust the value in line 9... to get the offset you wish. Line 7 also has a useful adjustment. I hope this helps. Quote Link to comment Share on other sites More sharing options...
Rehkitz Posted June 25, 2018 Author Share Posted June 25, 2018 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): Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 25, 2018 Share Posted June 25, 2018 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. Rehkitz and GameMonetize 1 1 Quote Link to comment Share on other sites More sharing options...
Rehkitz Posted June 25, 2018 Author Share Posted June 25, 2018 Thanks for the help. I got it running: https://www.babylonjs-playground.com/#JHB4AG#2 GameMonetize and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
waverider Posted June 26, 2018 Share Posted June 26, 2018 what about this, do you think it helps? press spacebar to move the model mesh. also rotate around to move in the direction you want https://www.babylonjs-playground.com/#11BH6Z#363 Quote Link to comment Share on other sites More sharing options...
pathei Posted May 23, 2019 Share Posted May 23, 2019 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted June 14, 2019 Share Posted June 14, 2019 We have a new forum: forum.babylonjs.com 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.