Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

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

Physics

Namespace: UnityEngine

Description

Global physics properties and helper methods.

Static Variables

AllLayersLayer mask constant to select all layers.
bounceThresholdTwo colliding objects with a relative velocity below this will not bounce (default 2). Must be positive.
DefaultRaycastLayersLayer mask constant to select default raycast layers.
gravityThe gravity applied to all rigid bodies in the scene.
IgnoreRaycastLayerLayer mask constant to select ignore raycast layer.
maxAngularVelocityThe default maximum angular velocity permitted for any rigid bodies (default 7). Must be positive.
minPenetrationForPenaltyThe minimum contact penetration value in order to apply a penalty force (default 0.05). Must be positive.
sleepAngularVelocityThe default angular velocity, below which objects start sleeping (default 0.14). Must be positive.
sleepVelocityThe default linear velocity, below which objects start going to sleep (default 0.15). Must be positive.
solverIterationCountThe default solver iteration count permitted for any rigid bodies (default 7). Must be positive.

Static Functions

CapsuleCastCasts a capsule against all colliders in the scene and returns detailed information on what was hit.
CapsuleCastAllLike Physics.CapsuleCast, but this function will return all hits the capsule sweep intersects.
CheckCapsuleReturns true if there are any colliders overlapping the capsule defined by the axis going from start and end and having radius in world coordinates.
CheckSphereReturns true if there are any colliders overlapping the sphere defined by position and radius in world coordinates.
GetIgnoreLayerCollisionAre collisions between layer1 and layer2 being ignored?
IgnoreCollisionMakes the collision detection system ignore all collisions between collider1 and collider2.
IgnoreLayerCollisionMakes the collision detection system ignore all collisions between any collider in layer1 and any collider in layer2.
LinecastReturns true if there is any collider intersecting the line between start and end.
OverlapSphereReturns an array with all colliders touching or inside the sphere.
RaycastCasts a ray against all colliders in the scene.
RaycastAllCasts a ray through the scene and returns all hits. Note that order is not guaranteed.
SphereCastCasts a sphere against all colliders in the scene and returns detailed information on what was hit.
SphereCastAllLike Physics.SphereCast, but this function will return all hits the sphere sweep intersects.