The title explains it.
here is my script so far.
function OnTriggerEnter (other : Collider) {
orbsLeft.orbsFound += 1;
}
its not adding 1 every time i hit the bead, which has the tag.
instead, its adding 1 half of the time i hit the wall or ledge.
thanks:p
Try:
function OnTriggerEnter (other : Collider) {
if(other.CompareTag("tag")){
orbsLeft.orbsFound += 1;
}
}
i think the problem is because OnTriggerEnter OnTriggerStay OnTriggerExit acts only when u enter inside the collider and not when it hits, so u must use a collider with “IsTrigger” checked true.
otherwise, You should use “OnControllerColliderHit” on the controller object :
function OnControllerColliderHit (hit : ControllerColliderHit) {
// when it hits an objects with a tag "old_paper"
if (hit.gameObject.tag == "old_paper"){
Destroy(hit.gameObject);
caracter_item.Add("old_paper");
audio.PlayOneShot(pick_item_1);
}
}