Forum rules - please read before posting.

Resetting Third Person Camera

I have a Shenmue-like setup in which the player can switch to first person view from the GameCameraThirdPerson (and back again). The problem is, when you switch back again to third person, the camera is still aimed at whatever direction it was in before, as I I do not use the "Always behind target?" option. Is there a way I can get the third person camera to default to being behind the character when switching back to it?

Comments

  • edited September 2019

    You can force the rotation through script by calling it's ForceRotation function.

    This would be best done from the OnSwitchCamera custom event, i.e.:

    private void OnEnable ()
    {
        EventManager.OnSwitchCamera += OnSwitchCamera;
    }
    
    private void OnDisable ()
    {
        EventManager.OnSwitchCamera -= OnSwitchCamera;
    }
    
    private void OnSwitchCamera (_Camera fromCamera, _Camera toCamera, float transitionTime)
    {
        if (toCamera is GameCameraThirdPerson)
        {
            GameCameraThirdPerson tpCam = (GameCameraThirdPerson) toCamera;
            float spinAngle = KickStarter.player.transform.eulerAngles.y;
            tpCam.ForceRotation (true, 0f, true, spinAngle);
        }
    }
    

    The Advanced ThirdPerson camera has this option built-in, however.

  • Excellent, thanks.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.