当前位置: 首页 > 工具软件 > Coffee2D > 使用案例 >

2d unity 多物体 射线_Physics2D.GetRayIntersectionAll 获取射线交点所有 - Unity5 中文 API 手册...

查宜修
2023-12-01

JavaScript => static function GetRayIntersectionAll(ray: Ray, distance: float = Mathf.Infinity, layerMask: int = DefaultRaycastLayers): RaycastHit2D[];

C# => static RaycastHit2D[] GetRayIntersectionAll(Ray ray, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers);

Parameters 参数

ray

The 3D ray defining origin and direction to test.

定义起源和方向进行测试的一条3D射线。

distance

Maximum distance over which to cast the ray.

射线的最大距离。

layerMask

Filter to detect colliders only on certain layers.

只在某些层检测碰撞器。

Returns 返回值

RaycastHit2D[] The cast results returned.

RaycastHit2D[] 返回投射结果。

Description 描述

Cast a 3D ray against the colliders in the scene returning all the colliders along the ray.

对场景内的碰撞器们投射一条3D射线,沿着射线返回所有接触到的碰撞器。

This is useful for finding colliders intersecting an arbitrary 3D ray.

这是对于找出一个碰撞器是非常有用的,用一条任意的3D射线去交叉(碰撞器)。

Note that this function will allocate memory for the returned RaycastHit2D array. You can use GetRayIntersectionNonAlloc to avoid this overhead if you need to make such calls frequently.

注意,这个函数将分配内存给返回的RaycastHit2D数组。如果你需要经常要调用这种功能,你可以使用GetRayIntersectionNonAlloc函数去避免这种(内存)开销。

Additionally this function is a 3D intersection test therefore any collision normals returned in the RaycastHit2D will be zero.

另外,这个函数是一个3D的相交测试因此任何在RaycastHit2D中返回的碰撞法线值将会是零。

 类似资料: