- Home /
Question by
Bokaii · Sep 18, 2014 at 05:01 AM ·
multiplayerfpsraycastall
Check if RaycastAll hits[i].point == null
How do I check if my hits[i].point== null??
Here's my code:
RaycastHit[] hits;
hits = Physics.RaycastAll (transform.FindChild("Main Camera").position, transform.FindChild("Main Camera").forward);
float minDist;
minDist = Mathf.Infinity;
for(int i=0;i<hits.Length;i++){
if(hits[i].transform != this.transform){
if(Vector3.Distance(transform.FindChild("Main Camera").position, hits[i].point)<minDist){
minDist = Vector3.Distance(transform.FindChild("Main Camera").position, hits[i].point);
print ("We hit: " + hits[i].collider.name);
}
}
}
I wan't to be able to check if I hit anything, and If I didn't then set:
hits[i].point = Camera.main.transform.position + (Camera.main.transform.forward*100f);
Comment
Your answer
Follow this Question
Related Questions
[CLOSED]RaycastAll Help 1 Answer
Bullet Effect (RaycastAll Question) 1 Answer
RaycastAll Detect if nothing hit 1 Answer
Photon Network Muzzleflash 0 Answers
[Closed]multiplayer camera script 2 Answers