Good day everyone . I have a little problem with detecting the collision of my fingers to my object . In my first stage my code for destroying object when it collides with my finger is here:
DetectionCollision.cs
using UnityEngine;
using System.Collections;
using Leap;
using Leap.Unity;
public class GetFlashLight : MonoBehaviour {
// Use this for initialization
void Start () {
}
private HandModel IsHand(Collider other){
if (other.transform.parent && other.transform.parent.parent && other.transform.parent.parent.GetComponent ()) {
return other.transform.parent.parent.parent.GetComponent ();
} else {
return null;
}
}
void OnTriggerEnter(Collider other) {
HandModel hand_model = IsHand (other);
if (hand_model != null) {
this.GetComponent<DisableObject> ().enabled = true;
} else {
this.GetComponent<DisableObject> ().enabled = false;
}
}
}
DisableObject.cs
public GameObject TurnOnFlashLight;
// Use this for initialization
void Start () {
TurnOnFlashLight.gameObject.SetActive (true);
}
The problem is when i apply the same code but different c# script (ofcourse) It didn't work . What do you think the problem is?