Understanding and declaring rays
I'm just trying to declare a Ray, and am following the same format that is shown in this post here, but for some reason, the comma between Ray.origin and Ray.direction is giving me an error in this code:
void RemoveGroup(){
int i;
for (i = 0; i < capturePosX.Count; i++) {
RaycastHit hit;
Ray ray = (new Vector3 (capturePosX[i], 5, capturePosY[i]), new Vector3 (0, 0, -1));
Physics.Raycast (ray, out hit);
if (hit.transform.tag != "board"){
Destroy (hit.transform.gameObject);
}
}
}
Why is this happening?
Answer by WillTM · Jun 01, 2016 at 04:04 PM
You've missed a bit. try Ray ray = new ray (new Vector3 (capturePosX[i], 5, capturePosY[i]), new Vector3 (0, 0, -1));
Oh my. I'm so embarrassed, it was so obvious. Thank you very much for your help.
Your answer
![](https://koobas.hobune.stream/wayback/20220612082037im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why does this script make unity crash? 1 Answer
error the name 'lightDirty' does not exist in current context. 1 Answer
When I open my game it says "Timed out while fetching user and orgs" Noob sorry. 1 Answer
Inactive in console even though its active in the inspector. 0 Answers
CS1023 An embedded statement may not be a declaration or labeled statement help 1 Answer