Forum rules - please read before posting.

Anyone Help me about SCRIPTS!!

edited July 2014 in Technical Q&A
using UnityEngine;
using System.Collections;

public class ComponentSwitch : MonoBehaviour {

// Use this for initialization
static void Start () {

}
// Update is called once per frame
static void Update () {
if(Input.GetKeyDown(KeyCode.Space))
{
GameCamera.enabled = !GameCamera.enabled;
}
}
}

basically here is my script,, the GameCamera, Refers to a GameCamera Created via AC all i want to do is toggle between turning it off and on,, can anyone help me with this script ? im in need of it,, my deadline is this coming wednesday and i'm almost done with my game and all i need to is to learn this script.. thank you guys i really appreciate some help now

Comments

  • May want to try replacing:

    GameCamera.enabled = !GameCamera.enabled;

    with:

    GameCamera.enabled = false;
  • edited July 2014
    You haven't created a GameCamera variable to link.

    using UnityEngine;
    using System.Collections;

    public class ComponentSwitch : MonoBehaviour
    {

      public GameCamera myGameCamera;

      void Update ()
      {
        if (Input.GetKeyDown (KeyCode.Space))
        {
         myG
    ameCamera.enabled = !myGameCamera.enabled;
    }
      }
    }

    You can then assign the appropriate GameCamera prefab into the script's inspector.
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.