Forum rules - please read before posting.

Multiple First Person Cameras

Hello,

We would like to use separate first person cams for different scenes. for example on a scene we want the cam to be higher, on another scene the field of view might be different.

so the question is, is it possible to set these values on runtime? when I change the first person cam transform on runtime the camera doesnt change as it probably aligns with the original position? and it doesnt change until I interact with an hotspot

I can also prepare multiple cam childs for the player prefab and enabled/disable them? when I switch camera to one of them it doesnt work

note: I can't use different player prefabs for different scenes as I am already using different players for speech files.

thanks

Comments

  • I set it using this custom action and having multiple first person camera on the player prefab but I am open if there is a better suggestion

            public int camNo;
    
            override public float Run ()
            {
                _Camera[] cams = KickStarter.player.gameObject.GetComponentsInChildren<_Camera>(true);
    
                for (int i = 0; i < cams.Length; i++)
                {
                if (i == camNo)
                        cams[i].gameObject.SetActive(true);
                    else
                        cams[i].gameObject.SetActive(false);
                }
    
                KickStarter.mainCamera.SetGameCamera(cams[camNo]);
    
                return 0f;
            }
    
            #if UNITY_EDITOR
    
            override public void ShowGUI ()
            {
                camNo = EditorGUILayout.IntField("Camera Index",camNo);
                AfterRunningOption();
            }
    
  • If the Action works, it works - it might be better to leave as is.

    However, I'd personally try tackling this from an animation standpoint instead. If you create a "middle GameObject" in your Hierarchy between the Player's root and a single FirstPersonCamera, then you can adjust the height of the camera by controlling that middle object's position.

    This position could then be controlled via animation. If your Player already has an Animator component, then a sub-layer in your Controller could be used solely to affect this middle object's y-position.

    This is a technique similar to that described in the crouching script on the wiki.

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.