Hi all, I am trying to set a panel to active when raycast hits an interactable yet it only works for my light switch interactable and not the door no matter what I do. Here is the script: Code (CSharp): public class Tofu_PlayerInteraction : MonoBehaviour { public Camera playerCam; public float range = 20f; public GameObject Panel; // Use this for initialization void Start() { } // Update is called once per frame void Update() { DetectInteractable(); } void DetectInteractable() { RaycastHit hit; if (Physics.Raycast(playerCam.transform.position, playerCam.transform.forward, out hit, range)) { Debug.Log(hit.transform.name); if (hit.collider.tag.Equals("Door")) { Panel.gameObject.SetActive(true); Debug.Log("Setting Panel"); if (Input.GetMouseButtonDown(0)) { hit.collider.GetComponent<Tofu_DoorInteract>().OpenDoor(); } } if (hit.collider.tag.Equals("LightSwitch")) { Panel.gameObject.SetActive(true); if (Input.GetMouseButtonDown(0)) { hit.collider.GetComponent<Tofu_LightSwitchInteract>().Switch(); } } else { Panel.gameObject.SetActive(false); } } } }
And btw the raycast works, after pressing down it executes the function opendoor and the door opens. I'm super confused. Also I did some testing and if I start with the panel on then when hovering over the door it will set it off. But where in the script did I ask it to turn of the panel object? its only supposed to turn off when it doesn't hit an object with the 2 tags.