I've started learning Unity slowly using C# and it's been a blast thus far!
I've run into a small problem (I hope it's a small problem) and gotten stuck, and have been somewhat questioning my sanity ever since.
In my main script which runs first I have code that generates a primitive (sphere) on the fly and attaches a script to it, the scrip checks to see if the sphere has been triggered.
Main script
bool createNav (Vector3 _start) {
GameObject nav = GameObject.CreatePrimitive(PrimitiveType.Sphere);
nav.AddComponent<NavTrigger>();
nav.collider.isTrigger = true;
nav.transform.localScale = new Vector3(1f,1f,1f);
nav.transform.position = _start;
return nav.GetComponent<NavTrigger>().Triggered;
}
My other script
private bool triggered = false;
void OnTriggerEnter() {
this.triggered = true;
}
public bool Triggered {
get { return this.triggered; }
}
Sadly, it still returns false regardless of it running the OnTriggerEnter code.
Please, if anyone has any ideas or suggestions at all let me know I will try and do just about anything to make this work.
Thank you very much for your help! :)
OnTriggerEnter requires a parameter (Collider other) or it won't match the signature Unity expects.
Also, as the documentation states: