Apologies for the basic nature of the question, but I’m having no luck following other solutions/tutorials. What I’m trying to do is set up a very basic trigger completely from scratch. I’ve done the following, but no dice. What am I missing?
-
I Create a new scene with a ground plane and two cubes.
-
Cube #1 is my “player” and gets a basic movement script.
-
Cube #1 is also given a rigidBody component
-
Cube #2 is my Trigger. I set “isTrigger” true within its boxCollider
-
I put the following code onto Cube #2. But at run, nothing fires.
function OnDrawGizmos() {
// Draw a transparent triggerbox for in-editor convenience Gizmos.color = Color.yellow; Gizmos.color.a = 0.5; Gizmos.DrawCube (transform.position, transform.localScale); } function onTriggerEnter(collision : Collider) { Debug.Log("Trigger has been hit by " + collision); } function onColliderEnter(other : Collider) { Debug.Log("Trigger has been hit by " + other); } function Start () { } function Update () { print("FML"); }
I’ve tried putting the same set of functions on the player script, made sure triggers work in example projects I’ve downloaded, and verified that a print or Debug.Log actually writes to the console (as in the FML example here) - but cannot for the life of me figure out what I’m missing when it comes to setting up a verrrrry basic trigger from scratch.
Help! I feel like once I understand whatever I’m missing here, I’ll be off to the races.