Hey I’m making a simple number game, I have created a prefab object with the a number at it’s animations and saved it as a prefab, I have two triggers:
- taped
- untaped
However when I created the next prefab for other number (with the same triggers) somehow they are all getting called. I have two scripts:
Number Script:
#pragma strict
private var anim:Animator;
private var tapped:boolean = false;
var value:int;
function Start () {
anim = GetComponent("Animator") as Animator;
}
function Update () {
}
function tap() {
if(!tapped) {
anim.SetTrigger("taped");
tapped = true;
} else {
anim.SetTrigger("untaped");
tapped = false;
}
}
and my InputHandler script:
#pragma strict
private var numberScript:numberScript;
function Start () {
numberScript = gameObject.GetComponent("numberScript");
Debug.Log("I'm atached to a numberScript with value: " + numberScript.value);
}
function Update () {
if(Input.GetMouseButtonDown(0)){
var mousePosition : Vector2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
var hitCollider : Collider2D = Physics2D.OverlapPoint(mousePosition);
Debug.Log("mouse pos "+mousePosition.x+" y "+mousePosition.y+" ");
if(hitCollider){
Debug.Log("Hit " + hitCollider.transform.name + " x " + hitCollider.transform.position.x + " y " + hitCollider.transform.position.y);
numberScript.tap();
}
}
}
Any ideas what might be happening?