This script highlights objects when you mouseOver them. I am trying to add the function that if you click your mouse on the highlighted object, another one will activate(A Child) and play its animation. The pop up isn’t working right at all, any ideas?
public GameObject popUp;
void Start () {
popUp = GameObject.FindWithTag ("Monster");
}
public void OnMouseEnter(){
HighLight (true);
Monster (true);
}
public void OnMouseExit(){
HighLight (false);
Monster (false);
}
public void Monster (bool appear){
Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit rayCastHit;
if(Physics.Raycast(ray.origin, ray.direction, out rayCastHit, Mathf.Infinity))
{
Monster monster = rayCastHit.transform.GetComponent<Monster>();
if(monster)
{
if(appear)
{
if (Input.GetMouseButton (0)) {
popUp.SetActive (true);
monster.PlayMonsterAnim();
} else {
popUp.SetActive (false);
}
}
}
}
}