Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Rigidbody.SweepTestAll

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function SweepTestAll(direction: Vector3, maxDistance: float = Mathf.Infinity, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): RaycastHit[];
public RaycastHit[] SweepTestAll(Vector3 direction, float maxDistance = Mathf.Infinity, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
public function SweepTestAll(direction: Vector3, maxDistance: float = Mathf.Infinity, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): RaycastHit[];
public RaycastHit[] SweepTestAll(Vector3 direction, float maxDistance = Mathf.Infinity, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);

Parameters

direction Direction to sweep the Rigidbody object.
distance Length of the sweep.

Description

Like Rigidbody.SweepTest, but returns all hits.

The sweep may return multiple hits against the same collider if more then one of the rigidbody's attached colliders would hit it.

Note that this function only works when a primitive collider type (sphere, cube or capsule) is attached to the rigidbody object - mesh colliders will not work, although they can be detected in the scene by the sweep.

This function can only return up to 128 hits.