Pretty simple, I have no idea how to check if the collider that a raycast hit is a trigger. How would I go about doing that? Preferably in C#.
RaycastHit hit;
Ray ray = new Ray(transform.position, transform.forward);
if(Physics.Raycast(ray, out hit))
{
if(hit.collider.isTrigger)
{
//Do the thing
}
}
Using the isTrigger property?
my code:
using UnityEngine;
public class DM_RayCastTrigger : MonoBehaviour
{
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitinfo;
if (Physics.Raycast(ray, out hitinfo))
{
print(hitinfo.transform.name + "::" + hitinfo.collider.isTrigger);
}
}
}
}
But I still don’t know why physic raycast could detected an trigger. It’s dosen’t make sense.
isent it because of the queryTriggerInteraction?