Skip to content

Commit 98df780

Browse files
authored
raycast with mouse snippet
1 parent ca8e754 commit 98df780

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Helpers/rayc.snippet

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
3+
<CodeSnippet Format="1.0.0">
4+
<Header>
5+
<Title>rayc</Title>
6+
<Shortcut>rayc</Shortcut>
7+
<Description>Code snippet for Mouse Raycast</Description>
8+
<Author></Author>
9+
</Header>
10+
<Snippet>
11+
<Declarations>
12+
<Literal Editable="false"></Literal>
13+
</Declarations>
14+
<Code Language="csharp"><![CDATA[if (Input.GetMouseButtonDown(0))
15+
{
16+
RaycastHit hit;
17+
var ray = cam.ScreenPointToRay(Input.mousePosition);
18+
if (Physics.Raycast(ray.origin, ray.direction, out hit, 999, layerMask))
19+
{
20+
Debug.Log(hit.transform.name);
21+
Debug.DrawLine(ray.origin, hit.point, Color.red, 10);
22+
Debug.DrawRay(hit.point, hit.normal, Color.green, 10);
23+
}
24+
}$end$]]></Code>
25+
</Snippet>
26+
</CodeSnippet>
27+
</CodeSnippets>

0 commit comments

Comments
 (0)