Address: http://blog.csdn.net/w88193363/article/details/38331205
Function Description
Static raycasthit2d []Raycastall (vector2Origin, vector2Direction, floatDistance = mathf. Infinity, intLayermask = defaultraycastlayers, floatMindepth =-mathf. Infinity, floatMaxdepth = mathf. Infinity ); Parameters
Origin |
The point in 2D space where the ray originates. |
Direction |
Vector representing the direction of the ray. |
Distance |
Maximum distance over which to cast the ray. |
Layermask |
Filter to detect coldocumers only on certain layers. |
Mindepth |
Only include objects with a Z coordinate (depth) greater than this value. |
Maxdepth |
Only include objects with a Z coordinate (depth) less than this value. |
Description
Casts a ray against colcyclers in the scene, returning all colcyclers that contact with it. Launch a ray in the scene to detect all collision machines (Collider)
[CSHARP] View plaincopyprint?
- // Layermask parameter indicates the layer to be ignored. The element attribute in the editor is sprite Renderer-> order in Layer
- // Set the object to be ignored as the corresponding layer, and then define layermask in the raycastall function as this layer. Then the ray will ignore this layer.
- Raycasthit2d [] rharfirst = physics2d. raycastall (qieobject. Transform. Position, vectordir, stagemanager. elementsize, 3 );