Specific camera coordinates based on players coordinates.

So i want to make my camera always be y (y coordinate) units over my player and xz (x and z coordinates) units offset from players y axis, while still having this piece of script work:

`if (Input.GetAxisRaw(“Mouse ScrollWheel”) > 0)
{
transform.LookAt(target.transform.position);
transform.RotateAround(target.transform.position, Vector3.up, 20 * Time.deltaTime * 10f);
// A = 1;
}

    if (Input.GetAxisRaw("Mouse ScrollWheel") < 0)
    {
        transform.LookAt(target.transform.position);
        transform.RotateAround(target.transform.position, Vector3.down, 20 * Time.deltaTime * 10f);
        //A = -1;
    }`

can someone help me?! I can already lock the y coordinate, but getting x and z to work is impossible for me.I also can’t just make the camera child to the player as the player is a rolling ball, and the camera totally freaks out when it starts to roll. I hope i explained what i want to do enough and if not just ask and I’ll try to clarify it a bit more.

The way I usually have the camera follow the player is by creating an empty GameObject that does only one thing: follows the player. It’s not a child of the player, it just constantly updates it’s transform to match the player’s position (or move towards the player’s position at a certain speed for camera smoothing). Make your camera a child of this empty GameObject, and it will maintain it’s position/rotation in relation to the player until you tell it to do otherwise.

The “otherwise” is where you lost me. You shared some code but didn’t explain at all what you’re end goal is, nor is the code commented. It seems you want the camera’s position to stay offset from the players, but for it’s rotation to point at a different target? The method I described should not affect this.