How to make Camera position Independent of its Rotation?

Hello, in this game, the camera is attached to the player as its child, the camera angle is fixed, even when the player rotates, but the camera position keeps changing every time the player rotates, as you can see below, the camera angle is fixed to one single direction, but when ever parent changes its rotation, it affects the child position, i dont want want my parents, rotation to affect my child Camera’s position…

//Camera Rotation Script

	void Awake () {
		//pos = transform.localPosition;
		rotation = transform.rotation;
	}




	void LateUpdate () {

		transform.rotation = rotation;
		//transform.localPosition = pos;
	
	}

//Camera Position Script

void Update () {
		if(this.transform.rotation.y == 0f)
			this.transform.localPosition = new Vector3(0f,13f,-4.5f);
		else if(this.transform.rotation.y == 180f)
			this.transform.localPosition = new Vector3(0f,13f,4.5f);
		else if(this.transform.rotation.y == 90f)
			this.transform.localPosition = new Vector3(-4.5f,13f,0f);
		else if(this.transform.rotation.y == 270f)
			this.transform.localPosition = new Vector3(4.5f,13f,0f);
	}

My solution would be to just don’t mak the camera a child in the first place, since you only want it to follow the position, you could do that by adding a script like this to your camera:

using UnityEngine;
using System.Collections;

public class RotatingExample1 : MonoBehaviour
{
    public Transform targetToFollow;
    public Vector3 targetOffset;

    private void LateUpdate()
    {
        transform.position = targetToFollow.position + targetOffset;
    }
}

If you still insist on keeping it a child however, then this code should help

using UnityEngine;
using System.Collections;

public class RotatingExample2 : MonoBehaviour
{
    public Vector3 offsetWorldPosition;
    private Quaternion fixedRotation;

    private void Awake()
    {
        fixedRotation = transform.rotation;
        //offsetWorldPosition = transform.localPosition; // Add this if you don't want to set the value in the inspector
    }

    private void LateUpdate()
    {
        transform.rotation = fixedRotation;
        transform.localPosition = transform.parent.worldToLocalMatrix.MultiplyVector(offsetWorldPosition);
    }
}