So, i have a script that enables a trigger in front of the player when they click lmb. but i don’t want that trigger to detect players through walls. so i added a script to the trigger:
private void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
RaycastHit hit;
if(!Physics.Linecast(transform.position, other.transform.position,out hit,layerMask,QueryTriggerInteraction.Ignore))
{
Debug.Log("Hit: " + hit.transform.name + " . " + hit.transform.tag);
}else
{
Debug.Log("Through Wall: " + hit.transform.name + " . " + hit.transform.tag);
}
}
}
but for some reason it hits the objects parent. that has a different layer and doesn’t have a collider.
AND its hitting the other players collider. which is what i want, But its saying its getting intersected???
this is probably hard to understand so just watch the video:
https://vimeo.com/671737307