Hey guys,
When I run my script with a single variable such as (== “Capsule1I”) inside of my if statement everything works the way I intend. When I attempt to use (== “Capsule1I” || “Capsule8I”), I always get true out, no matter what is detected by the linecast. Is there a problem with my syntax or method? There are a total of 4 possible capsules that I would like to use (== “Capsule1I” || “Capsule8I” || “Capsule16I” || “Capsule24I”). Is this possible or do I need to try something else?
var hit : RaycastHit;
var line : RaycastHit;
var cp : boolean = false;
function Update(){
if(Input.GetMouseButtonDown(0) && collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit, Mathf.Infinity)){
if(Physics.Linecast(Vector3(0,7.25,-5), Vector3(0,7.25,5), line)){
if(line.collider.gameObject.name == "Capsule1M"){
cp = true;
Debug.Log("check position true");
}
else {
cp = false;
Debug.Log("check position false");
}
}
}
}