Skip to content

Commit ed7802b

Browse files
committed
Update snippets & add raycast
1 parent 0d169f8 commit ed7802b

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

snippets.json

+28-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"\t\t{",
6161
"\t\t\t",
6262
"\t\t}",
63-
"\t}",
63+
"",
6464
"\t\tpublic void OnStartRunning(ref SystemState state)",
6565
"\t\t{",
6666
"\t\t\t",
@@ -316,5 +316,32 @@
316316
"}"
317317
],
318318
"description": "Create a Unity DOTS aspect (used to group related components)"
319+
},
320+
"Dots Create Raycast": {
321+
"prefix": "dcrc",
322+
"body": [
323+
"var collisionWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>().CollisionWorld;",
324+
"",
325+
"RaycastInput input = new RaycastInput()",
326+
"{",
327+
"\tStart = ${1},",
328+
"\tEnd = ${2},",
329+
"\tFilter = new CollisionFilter()",
330+
"\t{",
331+
"\t\tBelongsTo = ${3:~0u},",
332+
"\t\tCollidesWith = ${4:~0u}, //preset is collides w/ everything",
333+
"\t\tGroupIndex = ${5:0}",
334+
"\t}",
335+
"};",
336+
"",
337+
"RaycastHit hit = new RaycastHit();",
338+
"bool didHit = collisionWorld.CastRay(input, out hit);",
339+
"",
340+
"if (didHit)",
341+
"{",
342+
"\t${0}",
343+
"}"
344+
],
345+
"description": "Create a Unity Physics (the DOTS package) raycast. NOTE: requires Unity Physics package to be installed and a using directive - using Unity.Physics;"
319346
}
320347
}

0 commit comments

Comments
 (0)