Why Does My Script not work?

I wrote a script about getting these two cameras (1st and 3rd person) to switch at the press down and up of the c key. here is the code:

using UnityEngine;
using System.Collections.Generic;


public class cameraswitch : MonoBehaviour {
    public GameObject sideCam;
    public GameObject caracterCam;

    void Start() {
        if (Input.GetKeyDown(KeyCode.C)) {
            sideCam.SetActive(true);
            caracterCam.SetActive(false);
        }
        if (Input.GetKeyUp (KeyCode.C)) {
            sideCam.SetActive (false);
            caracterCam.SetActive (true);
        }
    }
}

I made it so I could just drag the cameras I needed and it all working correctly. Evidently, I messed up somewhere… Help is wanted! xD, thanks,
steel

What have you done with this script? And in what way, exactly, is it not working?

This code should be in Update, not Start.

2 Likes

This. Start only runs once, at the beginning of the GaneObjects life. Update runs every frame.

Deja vu! Looks like some posts were lost in the hack. Fortunately, I didn’t say anything of actual value. :slight_smile: