Physics¶
Use these methods to interact with Unity’s physics engine.
Static members¶
Member |
Description |
---|---|
|
The gravity applied to physics objects. |
Static methods¶
Method |
Description |
---|---|
Casts a ray from start to end until it collides with a target. |
|
Casts a ray through the scene until it collides with a target. |
|
Casts a ray through the scene registering all collisions with target objects. |
|
Casts a sphere ray from start to end until it collides with a target. |
|
Casts a sphere ray from start to end until it collides with a target. |
Details¶
-
class
Physics
¶ -
static Vector3
gravity
¶ The gravity applied to physics objects.
-
static bool
CheckBox
(Vector3 center, Vector3 halfExtents, Quaternion orientation, RaycastTarget target)¶
-
static bool
CheckCapsule
(Vector3 start, Vector3 end, float radius, RaycastTarget target)¶
-
static bool
CheckSphere
(Vector3 position, float radius, RaycastTarget target)¶
-
static object
Linecast
(Vector3 start, Vector3 end, RaycastTarget target)¶ Casts a ray from start to end until it collides with a target.
- Returns
A RaycastHit if a collision occurs along the ray; otherwise nil.
-
static array<Collider>
OverlapBox
(Vector3 center, Vector3 halfExtents, Quaternion orientation, RaycastTarget target)¶
-
static array<Collider>
OverlapCapsule
(Vector3 start, Vector3 end, float radius, RaycastTarget target)¶
-
static array<Collider>
OverlapSphere
(Vector3 position, float radius, RaycastTarget target)¶
-
static object
Raycast
(Ray ray, float range, RaycastTarget target)¶ Casts a ray through the scene until it collides with a target.
- Parameters
ray – Test for collisions along this ray.
range – Look no further than this [meters].
target – Test for collisions with these things.
- Returns
A RaycastHit if a collision occurs along the ray; otherwise nil.
-
static array<RaycastHit>
RaycastAll
(Ray ray, float range, RaycastTarget target)¶ Casts a ray through the scene registering all collisions with target objects.
- Parameters
ray – Test for collisions along this ray.
range – Look no further than this [meters].
target – Test for collisions with these things.
- Returns
An array of RaycastHits that occured along the ray.
-
static object
Spherecast
(Ray ray, float radius, float range, RaycastTarget target)¶ Casts a sphere ray from start to end until it collides with a target.
- Returns
A RaycastHit if a collision occurs along the ray; otherwise nil.
-
static object
SpherecastAll
(Ray ray, float radius, float range, RaycastTarget target)¶ Casts a sphere ray from start to end until it collides with a target.
- Returns
A RaycastHit if a collision occurs along the ray; otherwise nil.
-
static Vector3