I have been stuck on this for hours. My movement code uses raycasting since it is a grid based. I started working with probuilder and it seems that the collider detection is quite unreliable and the mesh collider is not detected most of the time.
Here is the mesh collider and the raycast code:
bool CanMove(Vector3 direction)
{
if (direction.z != 0)
{
if (Physics.Raycast(zAxisOriginA, direction, out hit, rayLength))
{Debug.Log(hit.collider);
if (hit.collider != null)
{
Debug.Log(hit.collider);
return false;
}
}
if (Physics.Raycast(zAxisOriginB, direction, out hit, rayLength))
{
Debug.Log(hit.collider);
if (hit.collider != null)
{
return false;
}
}
}
else if (direction.x != 0)
{
if (Physics.Raycast(xAxisOriginA, direction, out hit, rayLength))
{Debug.Log(hit.collider);
if (hit.collider != null)
{
Debug.Log(hit.collider);
return false;
}
}
if (Physics.Raycast(xAxisOriginB, direction, out hit, rayLength))
{Debug.Log(hit.collider);
if (hit.collider != null)
{
Debug.Log(hit.collider);
return false;
}
}
}
return true;
}