Question by
fabiankuchling · Apr 22, 2020 at 09:32 AM ·
3dcamera-movement
Fixed angle relative between player and camera when player traverses around sphere,Relative angle between Player and Camera should stay the same when player circling around sphere
I tried a lot of things as of now but nothing worked for me.
This was my latest approach but the camera always stays at a fixed angle relative to world space and not to my player.
void Update()
{
float playerAngle = Vector3.Angle(playerScript.transform.forward, Vector3.zero);
float sinAlpha = Mathf.Sin(playerAngle + degreesToPlayer);
float cosAlpha = Mathf.Cos(playerAngle + degreesToPlayer);
float triangleGK = sinAlpha * distanceToPlayer; //GK is Y axis
float triangleAK = cosAlpha * distanceToPlayer; //AK is X axis
Vector3 camPos = new Vector3(playerScript.transform.position.x - triangleAK, playerScript.transform.position.y + triangleGK, playerScript.transform.position.z);
transform.LookAt(playerScript.transform);
transform.position = camPos;
}
Currently it looks like this:
And when i move further it dips into the sphere:
I hope someone has an idea.
Comment
Your answer
Follow this Question
Related Questions
Object and camera following mouse 0 Answers
Cinematic feel for 3D First Person Camera 0 Answers
Using two cameras to blend regular 2D orthographic with 3D isometric orthographic elements 0 Answers
Third person Camera rotation problem 2 Answers
3D click and drag Camera Movement is shaking rapidly 0 Answers