- Home /
Duplicate Question
Raycast not visible
Hey everyone, Im making an RTS and im trying to begin by having a raycast able to be visible on click so that i can detect if a unit is being selected by the mouse (if there is an easier way let me know). Anyways, its not showing up, and I feel ive tried about everyting. Here is my code below:
if (Input.GetMouseButtonDown (0)) { //if left click...
startClick=Input.mousePosition; //give the position
//test code
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); //trying to single select
RaycastHit hit;
Debug.DrawRay (ray.origin, startClick * Mathf.Infinity, Color.red);
if (Input.GetMouseButtonDown (0)) {
if(Physics.Raycast(ray,out hit, Mathf.Infinity)){
//startClick=hit.point;
}
}
Are you playing in full screen or maximized? $$anonymous$$ake sure you have 'Gizmos' enabled at the top right
Im playing it in the window. I didnt know you have to actually click on gizmos, but it still doesnt show up.
Answer by Jinxology · Apr 17, 2014 at 05:22 AM
DrawRay only shows up in the Scene view, not in the Game view.
It's only for debugging.
You looking in the Scene view? Also, zoom way out, maybe your coordinates are off.
Follow this Question
Related Questions
how detect "OnRaycastOut" 1 Answer
how to select an object with raycasting 1 Answer
Raycast returns null for no apparent reason 0 Answers
Raycast goes through 1 Answer
Raycasting and foreach loops 1 Answer