I have this function:
function noObstacles(checkpoint : GameObject){
var hitvalue : RaycastHit;
Physics.Linecast(transform.position,checkpoint.transform.position,hitvalue);
if (hitvalue.collider!=null && hitvalue.collider.gameObject.tag=="Jumpable") return false;
else return true;}
That I use to simply verify that a AI-controlled character can “see” a checkpoint, which I use to guide it around the level. My problem is that this only seems to work more or less 80% of the time. Some other times it doesn’t work: I tried to check with Debug.DrawLine and saw that the Linecast just passes through the platforms even if they’re tagged as Jumpable, for no apparent reason…
Can it happen if there is some other object hit by the Linecast (including the character and the checkpoint)? If that’s the case how can I avoid the problem? Any other solution?
Thanks in advance!