I can't figure out what is wtong with my code, I wan't the score to reset when I collide with a specific tag but nothing happens? How can I do this with javascript.
#pragma strict
static var score : int = 0;
var scoreText : UnityEngine.UI.Text;
public var impact : AudioClip;
function OnTriggerEnter2D(other : Collider2D)
{
if (other.gameObject.CompareTag("Player"))
{
GameObject.Find("CoinPickUp").GetComponent.().PlayOneShot (impact, 1.0F);
//audio.PlayOneShot(impact, 0.7F);
Destroy( gameObject);
score += 1;
}
}
function OnColliderEnter2D (coll : Collision2D)
{
if (coll.gameObject.CompareTag("water"))
{
score = 0;
}
}
function OnGUI ()
{
scoreText.text = "" + score;
}
↧