Skip to content

Commit d5fb057

Browse files
committed
Added layermask to crosshair
1 parent 50beda9 commit d5fb057

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

NewAPI/seyahdoo/crosshair/Crosshair.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
///Changelog:
99
///30.03.2017 -> Created by seyahdoo
10+
///31.03.2017 -> Added Layermask to raycast
1011

1112
///usage:
1213
///Attach to any camera or pointer and this will trigger CrosshairAware objects
@@ -61,13 +62,18 @@ public static void SetupCrosshair()
6162
private CrosshairAware _crosshairAware;
6263
private Collider _lastCollider;
6364

65+
/// <summary>
66+
/// What layer to look for?
67+
/// </summary>
68+
public LayerMask layerMask = -1; //Default to everything
69+
6470
void Update()
6571
{
6672
//do the raycasting
6773
RaycastHit hit;
6874

6975
//if i found something
70-
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit))
76+
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit,float.MaxValue,layerMask))
7177
{
7278
//did i found a new thing?
7379
if(_lastCollider != hit.collider)

0 commit comments

Comments
 (0)