Hello, I’ve been working on a script to disable a script in one scene, but to keep it enabled on another. However, I’ve been getting an error which I thought was to do with constructors, not scripts. I’ve tried adding new in front of GetComponent, but that ended up giving a CS0246 error instead.
using UnityEngine;
using System.Collections;
public class Reset : MonoBehaviour
{
public Alive alive;
void Start()
{
alive = GetComponent(Alive);
}
void Update()
{
if (Input.GetKeyDown("z"))
{
alive.enabled = true;
Application.LoadLevel(1);
}
if (Input.GetKeyDown("x"))
{
alive.enabled = false;
Application.LoadLevel(0);
}
}
}
The error is:
Assets/Reset.cs(10,38): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected