Hello again, i got a small problem … i am using a raycast to detect the collider of a certain layer(LayerA)
The problem is that the gameobject that contain the collider in the LayerA as a child mark as LayerB that contain a bigger collider and is triggered.
it seams that the raycast detect the collider of the object in the LayerB and the one in the LayerA.
i want the raycast to detect only the LayerA
Here’s the part of the code:
if(Physics.Raycast(PlayerCamera.transform.TransformPoint(0,0,0.5f), PlayerCamera.transform.forward, out Detection,DetectionDistance))
{
if (Detection.transform.gameObject.layer == LayerMask.NameToLayer("LayerA") )
{
DetectedItem = Detection.transform.gameObject;
if(Input.GetButtonDown("Action"))
{
//Do Something
}
}
}
it seems that i can press the “Action” button even if the raycast detect the LayerB