I’ve been searching Unity answers for how to do this, and it’s covered a lot. But when I try to do it, I still have trouble getting one script to recognize the existence of another:
I have a script called FlyingActivator on an object called Player. In it there is a public boolean variable called EnableFlying.
I need to set the EnableFlying variable to !EnableFlying from another script (“WaitToFly”). This is a stripped down version of what I’m using to do it:
using UnityEngine;
using System.Collections;
public class WaitToFly : MonoBehaviour
{
void Start()
{
GameObject g = GameObject.Find("Player");
FlyingActivator e = g.GetComponent<FlyingActivator>();
e.EnableFlying = !EnableFlying;
}
}
Except I’m getting this error:
The type or namespace name `FlyingActivator’ could not be found. Are you missing a using directive or an assembly reference.