So, i have two objects, one is raycasting for the secon one (raycaster and target). The problem i have is when i set any costrains to target, no matter if it is position or rotation the raycaster isn’t “finding it”. Raycast works fine when there are no constrains.
Here is also my code:
private void CheckRaycast()
{
Ray ray = new Ray (transform.position, transform.forward);
RaycastHit hit;
if(Physics.Raycast (ray, out hit, maxDistance))
{
if(hit.transform.GetComponent<Interactible>())
{
Debug.Log("Hit int");
SetIntScript(hit.transform.GetComponent<Interactible>());
}
if(hit.transform.GetComponent<Interactible>() != intScript)
{
Debug.Log("Hit but no int");
Exit();
}
}
else
{
Debug.Log("No hit");
}