I have a problem that I don’t know how to fic… I’m a noob when it comes to c#. I want a collider to detect a specific gameobject called “stones”, not every object that collides with it. here is the code i have written so far:
using UnityEngine;
using System.Collections;
public class stonecollider : MonoBehaviour {
stonecounter myPlayerScript;
void Awake()
{
myPlayerScript = transform.parent.GetComponent<stonecounter>();
}
void OnTriggerEnter(Collider theCollision)
{
GameObject collisionGO = theCollision.gameObject;
myPlayerScript.theScore++;
}
}
and the other script:
using UnityEngine;
using System.Collections;
public class stonecounter : MonoBehaviour {
public int theScore = 0;
void OnGUI()
{
GUILayout.Label("Score: " + theScore);
}
}