Hi everyone, I don’t know whats wrong here. I using raycasts for my AI to avoid obstacles and I don’t want them to avoid some obstacles such as the player or obstacles that can be moved. But they avoid everything. So its suppose to avoid everything except player and movable objects, but instead it just avoids everything.
Here’s one snippet of the code. I have multiple raycasts but they’re all the same only with a different origin and ray distance.
if(Physics.Raycast(transform.position, transform.forward, hit, rayDistance1))
{
if(hit.collider.gameObject.tag != "Player" || hit.collider.gameObject.tag != "Movable" || hit.collider.gameObject.tag != "WeaponPickup");
{
Debug.DrawLine(transform.position, hit.point, Color.red);
lookDirection += hit.normal * repelForce;
}
}
else
{
Debug.DrawRay(transform.position, transform.forward * rayDistance1, Color.yellow);
}
I don’t know whats wrong. I tried both hit.collider.tag != “Player” and hit.transform.tag != “Player” and the hit.collider.gameObject.tag != “Player”, but its the same result for anything.
Thank you.