返回介绍

Physics2D.BoxCastAll 箱形投射所有

发布于 2019-12-18 15:38:16 字数 3478 浏览 1117 评论 0 收藏 0

JavaScript => static function BoxCastAll(origin: Vector2, size: Vector2, angle: float, direction: Vector2, distance: float = Mathf.Infinity, layerMask: int = DefaultRaycastLayers, minDepth: float = -Mathf.Infinity, maxDepth: float = Mathf.Infinity): RaycastHit2D[];
C# => static RaycastHit2D[] BoxCastAll(Vector2 origin, Vector2 size, float angle, Vector2 direction, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, float minDepth = -Mathf.Infinity, float maxDepth = Mathf.Infinity);

Parameters 参数

originThe point in 2D space where the shape originates.
在2D空间中,形状的发源点。
sizeThe size of the shape.
形状的大小。
angleThe angle of the shape.
形状的角度。
directionVector representing the direction of the shape.
代表形状方向的向量。
distanceMaximum distance over which to cast the shape.
形状投射的最大距离。
layerMaskFilter to detect Colliders only on certain layers.
只在某些层过滤检测碰撞器。
minDepthOnly include objects with a Z coordinate (depth) greater than this value.
只包括Z坐标(深度)大于这个值的对象。
maxDepthOnly include objects with a Z coordinate (depth) less than this value.
只包括Z坐标(深度)小于这个值的对象。

Returns 返回值

RaycastHit2D[] The cast results returned.
投射结果的返回值是RaycatHit2D[]类型。

Description 描述

Casts a box against colliders in the scene, returning all colliders that contact with it.
对场景内的碰撞器们投射出一个箱子,返回所有投射接触到碰撞器。

A BoxCast is conceptually like dragging a box through the scene in a particular direction. Any object making contact with the box can be detected and reported.
方形投射就好像在场景中拖着一个Box向特定的方向移动。任何物体接触到Box会被检测到并报告。

This function is similar to the BoxCast function but instead of detecting just the first collider that is hit, an array of all colliders along the path of the box is returned. The colliders in the array are sorted in order of distance from the origin point. The layerMask can be used to detect objects selectively only on certain layers (this allows you to apply the detection only to enemy characters, for example).
这个函数与BoxCast函数类似,但不是仅仅只返回第一个投射到的碰撞器,而是返回一个所有被检测到的碰撞器的数组。数组内的碰撞器根据他和投射发源点之间的距离排序。图层遮罩可以用于指定检测特定某些图层的对象(比如:这允许您设置检测只适用于敌人角色)。

The returned RaycastHit2D returns both the point and normal of the contact where the box would touch the collider. It also returns the centroid where the box would be positioned for it to contact at that point.
返回的RaycastHit2D类型内包含了投射方形接触到碰撞器的接触点和法线信息。它还返回方形被定位在接触点时的中心点。

See Also: LayerMask class, RaycastHit2D class, BoxCast, BoxCastNonAlloc, DefaultRaycastLayers, IgnoreRaycastLayer, raycastsHitTriggers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文