Camera rotation around player at specified point

Hi there.
Forgive me if this is a really simple thing to do but I’ve been racking my brains over it and I can’t seem to figure out the code needed.

I intend to use an empty game object with a box collider to trigger the camera’s rotation 90 degrees around the player when the player passes through it, and rotate back to original point if the player passes through it again (ex. See Pokémon Omega Ruby/Alpha Sapphire Battle Resort

)

Create a game object and make the camera child of that game object, position the camera where you need it, then rotate that object 90 degrees when you want (this will work if the camera is a child of the player, so you’ll have Player->gameobject->camera). If you’re using a script to make the camera follow the character then you’ll need to do something like this:

Vector3 direction = Camera.transform.position - player.transform.position; // calculate the current direction from the player to the camera
direction = Quaternion.AngleAxis(90, Vector3.up); // Rotate that direction
Camera.transform.position = direction.normalized * CameraDistanceFromPlayer; // Normalize and set the distance from player
Camera.transform.rotation.SetLookRotation(-direction, Vector3.up); // Set the camera to watch the player

Hi, thanks for the quick response, sorry that I couldn’t respond earlier myself. Yes my camera follows the player, currently without rotating. I want it to rotate at specific places rather than when I turn the player (As shown in the video in my OP). I think your script just turns the camera when the player turns, since from your wording you’re telling me to apply it to the original camera script. Please correct me if I’m wrong though, I’m a little slow today.

EDIT: Also, my Unity doesn’t seem to accept Quaternions and Vector3’s being used together, giving the error “Cannot implicitly convert UnityEngine.Quaternion to UnityEngine.Vector3”

EDIT#2: This is the camera script if it helps. The camera is already a child of the player object.

public class CameraFollow : MonoBehaviour {
    public GameObject target;
    Vector3 offset;
    // Use this for initialization
    void Start () {
        offset = transform.position - target.transform.position;
    }
   
    // Update is called once per frame
    void LateUpdate () {
        Vector3 desiredPosition = target.transform.position + offset;
        transform.position = desiredPosition;
    }
}

rotating around a point function…

Thank you for that LeftyRighty but I have a question about it - I see the axis and the angle but what is the trigger for this rotation? Might be staring me in the face…

I tried applying this code to the empty GameObject I was intending to use to initiate the rotation, but nothing happened when I passed through it (The box collider of the game object is large enough for the player to pass through). Am I applying it to the wrong thing? or am I missing something? If I apply it to the camera follow script I mentioned earlier then the camera just constantly rotates with no trigger and without stopping…

without specifics about how you are calling the rotation function, no idea… RotateAround is just a rotation function, you control how/when/forHowLong/byHowMuch it gets called.

That’s the thing. I want to call a 90 degree camera rotation when I get to a certain point (specifically, a turn whereby continuing in that direction would obscure the player behind a wall or other such obstacle) and return to normal if I go back round the corner again so I assumed I should apply it to a box collider on an empty game object placed at the aforementioned corner.