Hey everyone! I tried making a 1st to 3rd person camera. Like if you push a button, you would switch from 1st to 3rd person. I attached it to the standard Unity FirstPersonController. And I did, put the 1st and 3rd person camera in the slots. But This script doesn’t work, does anyone know whats wrong?
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
public Camera camera1;
public Camera camera2;
void Start()
{
if(Input.GetButtonDown("Fire2"))
{
camera2.enabled = true;
camera1.enabled = false;
}
else
{
camera2.enabled = false;
camera1.enabled = true;
}
}
}
I think you need both your cameras tagged as “MainCamera” in the inspector.
Also, you’re putting your code in “start” rather than “Update”. If you want this to happen any time you press the button, it needs to go in the Update section instead.
You have put the code in the start function. The start function is only run once, just before the first Update call. You need to put it in the update function call instead:
Oh, okay! Thanks!
– anon79141775