Hi guys, I want to assign bone1 to the public Collider other variable in the start function. I'm able to do it from the inspector, but I would like to do it directly from the script. How should I do?
(I am working with unity, c# and LMHeadMountedRig).
Many thanks !
public class touch : MonoBehaviour {
public Collider other
public void Start()
{
GameObject hf = GameObject.Find("bone1"); //NOTCORRECT
other = hf.GetComponent<Collider>(); //NOTCORRECT
}
public void Update()
{
OnTriggerEnter( other);
}
void OnTriggerEnter(Collider other)
{
Debug.Log("Collision Trigger Event " + other);
FingerModel finger = other.GetComponentInParent<FingerModel>();
if (finger)
{
GetComponent<Renderer>().material.color = Color.red;
}
}
}