Hi, I’m making my first unity game at the moment.
This is my problem:
I have 4 spawnpoints near the center of the screen. These spawn various rigidbodies which move towards the screen. our objective is to put them in the right bin using swipe gestures.
At the moment I’m trying to program the colliders to destroy incoming rigid bodies and also increment the score when appropriate. This is what I have :
using UnityEngine;
using System.Collections;
public class GlassBin : MonoBehaviour {
public GameObject score; // reference to the Scoreboard on our canvas.
public AudioClip ScoreSound; // reference to our score sound.
public int scoreValue = 100;
void onTriggerEnter(Collider other) // if junk hits bin trigger
{
if (other.tag == "MetalJunk") {
Destroy (other.gameObject);
Debug.Log ("MetalJunk triggered on GlassBin.");
}
if (other.tag == "PlasticJunk") {
Destroy (other.gameObject);
Debug.Log ("PlasticJunk triggered on GlassBin.");
}
if (other.tag == "PaperJunk") {
Destroy (other.gameObject);
Debug.Log ("PaperJunk triggered on GlassBin.");
}
if (other.tag == "GlassJunk") {
Destroy (other.gameObject);
Debug.Log ("GlassJunk triggered on GlassBin.");
int currentscore = int.Parse (score.GetComponent <GUIText>().text) + scoreValue;
score.GetComponent<GUIText>().text = currentscore.ToString ();
}
}
}
I have 4 of these scripts, one for each bin (GlassBin,MetalBin,PlasticBin,PaperBin).
Only difference is which trigger grants the player a score.
The objects i’m spawning aren’t triggering these though! ( I have tagged the appropriately!)
All of them are 3d meshes with a mesh collider and a rigidbody. Gravity is off for these objs.
I have isTrigger set to true on my “Bins”.
The Debug.Logs don’t play.
What am I missing?