Forum rules - please read before posting.

Camera Does Not Register as Switched in First Person?

In my current setup, the game is usually 3D third person direct control, with the camera switching at certain locations through the use of triggers if not in first person - but the player can switch to first person at any time using an active input, and continue to move around.

If you enter one of these triggers while in first person, there is an action list that should switch camera, then immediately switch back to first person, so as to not disorient the player. However, the problem is it only registers as a new camera if you give it a transition time with wait until finish selected, and so when you exit first person, it reverts back to the old camera that was in use before the trigger was entered.

(Do let me know if I have not explained this well enough, I will try and elaborate).

Comments

  • edited December 2019

    I think I understand the scenario, but what do you mean by "register"? Are you trying to use the "Last gameplay camera?" field when going from First to Third-person?

    You could try hooking into the OnSwitchCamera event to record calls made to non-FP cameras, so that you can transition to it through function call:

    private _Camera lastThirdPersonCamera;
    private float lastTransitionTime;
    
    private void OnEnable ()
    {
        EventManager.OnSwitchCamera += OnSwitchCamera;
    }
    
    private void OnDisable ()
    {
        EventManager.OnSwitchCamera -= OnSwitchCamera;
    }
    
    private void OnSwitchCamera (_Camera fromCamera, _Camera toCamera, float transitionTime)
    {
        if (!(toCamera is FirstPersonCamera))
        {
            lastThirdPersonCamera = toCamera;
            lastTransitionTime = transitionTime;
        }
    }
    
    public void SwitchToLastThirdPersonCamera ()
    {
        KickStarter.mainCamera.SetGameCamera (lastThirdPersonCamera, lastTransitionTime);
    }
    
  • Thank you, and yes I am trying to use the Last gameplay camera field when attempting to switch back. By not registering, I mean that the camera switch is ignored if it is also immediately switched again in the very next action, so if you attempt to switch back to it again from first person, it will instead switch to the camera that was in use before first person was used - as though the switch never happened at all. Like so:

    • Gameplay starts, using default Camera A
    • Player activates first person mode, switches to first person camera
    • Player enters trigger during first person - the trigger action list switches to Camera B - but immediately switches to first person cam again as player is still in first person (as intended)
    • Player exits first person - cam should switch to last gameplay camera (Camera B), but instead switches to Camera A.
  • edited December 2019

    Understood, will look into it.

  • That sunglasses emoji should just say Camera B by the way, lol.

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.