This is driving in me insane, and it worked before, but not now. I have my player camera set up as a child of the player. Then I have some small key pressing statements to change the position of the camera, but when I press one of them, it sets the camera to the world axis and not the player. The second thing I need to figure out is how to lerp each position, so when you press a new position, it smoothly goes to that position instead of jumping it.
UPDATED:
So, I figured out my lerping problem, but I am still stuck with my child object not moving around the player’s axis. It’s still stuck to the world’s axis.
Here’s my script:
[Header(“Camera Info”)]
[SerializeField]
private GameObject PlayerCamera;
[SerializeField]
private Transform PlayerCamPosition;
[SerializeField]
private Transform FocalPoint;
public float Smoother;
[Space]
public Vector3[] CameraPositions;
private Vector3 Current;
private void Start()
{
if (Camera.main != null)
{
Camera.main.transform.gameObject.SetActive(false);
}
Current = CameraPositions[0];
}
private void Update()
{
SetPosition();
ChangeCamPosition(Current);
}
private void SetPosition()
{
PlayerCamera.transform.LookAt(FocalPoint);
if (Input.GetKeyDown(KeyCode.Alpha1))
{
Current = CameraPositions[1];
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
Current = CameraPositions[0];
}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
Current = CameraPositions[2];
}
}
private void ChangeCamPosition(Vector3 Position)
{
PlayerCamera.transform.position = Vector3.Lerp(PlayerCamPosition.position, Position, Smoother);
}