Physics
The Physics class is essential for managing global physical simulations in scenes, such as gravity, collisions, and interactions between GameObjects. It also allows control over settings like gravity and layer collisions. Unity's Physics Documentation
Properties
Specify the minimum collision velocity for an object to bounce. Unity's Physics.bounceThreshold Documentation
Define the minimum distance between colliders for them to be considered in contact. Unity's Physics.defaultContactOffset Documentation
Control the global gravity in the physics simulation, defaulting to Earth's gravity. Unity's Physics.gravity Documentation
Decide if physics queries should detect hits on collider backfaces. Unity's Physics.queriesHitBackfaces Documentation
Determine whether physics queries interact with trigger colliders. Unity's Physics.queriesHitTriggers Documentation
Set the velocity threshold below which GameObjects are considered static or immobile. Unity's Physics.sleepThreshold Documentation
Methods
Parameters
meshID
convex
Returns
Parameters
Parameters
Parameters
center
halfExtents
direction
orientation
maxDistance
layerMask
Returns
Parameters
Returns
Parameters
Returns
Parameters
center
halfExtents
direction
orientation
maxDistance
layerMask
Returns
Returns
Returns
Returns
Parameters
Returns
Parameters
Returns
Parameters
position
radius
Returns
Parameters
Returns
Calculate the closest point to a given position on a collider's surface. Unity's Physics.ClosestPoint Documentation
Parameters
point
Position to check against.
collider
Collider to check.
position
Collider's position.
rotation
Collider's rotation.
Returns
Closest point on the collider.
Parameters
colliderA
positionA
rotationA
colliderB
positionB
rotationB
Check if collisions between two specific colliders are ignored. Unity's Physics.GetIgnoreCollision Documentation
Check if collisions between any colliders in two layers are ignored. Unity's Physics.GetIgnoreLayerCollision Documentation
Parameters
layer1
First layer ID.
layer2
Second layer ID.
Returns
True if collisions are ignored, false otherwise.
Prevent physics engine from processing collisions between two specified colliders. Unity's Physics.IgnoreCollision Documentation
Prevent physics engine from processing collisions between two specified colliders. Unity's Physics.IgnoreCollision Documentation
Make physics engine ignore all collisions between colliders in two specified layers. Unity's Physics.IgnoreLayerCollision Documentation
Parameters
layer1
First layer ID.
layer2
Second layer ID.
Returns
Make physics engine ignore all collisions between colliders in two specified layers. Unity's Physics.IgnoreLayerCollision Documentation
Parameters
layer1
First layer ID.
layer2
Second layer ID.
ignore
Whether to ignore collisions.
Returns
Returns
Parameters
Returns
Parameters
Returns
Returns
Returns
Find all colliders touching or inside an imaginary sphere, useful for area damage or proximity checks. Unity's Physics.OverlapSphere Documentation
Parameters
position
Sphere center.
radius
Sphere radius.
Returns
Array of colliders within the sphere.
Find all colliders touching or inside an imaginary sphere, useful for area damage or proximity checks. Unity's Physics.OverlapSphere Documentation
Parameters
position
Sphere center.
radius
Sphere radius.
layerMask
LayerMask to selectively ignore colliders.
Returns
Array of colliders within the sphere.
Trace a path in 3D space to detect colliders, useful for implementing bullet paths or line-of-sight features. Unity's Physics.Raycast Documentation
Parameters
ray
Defines the origin and direction of the ray.
Trace a path in 3D space to detect colliders, useful for implementing bullet paths or line-of-sight features. Unity's Physics.Raycast Documentation
Parameters
ray
Defines the origin and direction of the ray.
maxDistance
The maximum distance to check for collisions.
Trace a path in 3D space to detect colliders, useful for implementing bullet paths or line-of-sight features. Unity's Physics.Raycast Documentation
Parameters
ray
Defines the origin and direction of the ray.
maxDistance
The maximum distance to check for collisions.
layerMask
LayerMask to selectively ignore colliders.
Trace a path in 3D space to detect colliders, useful for implementing bullet paths or line-of-sight features. Unity's Physics.Raycast Documentation
Trace a path in 3D space to detect colliders, useful for implementing bullet paths or line-of-sight features. Unity's Physics.Raycast Documentation
Parameters
Trace a path in 3D space to detect colliders, useful for implementing bullet paths or line-of-sight features. Unity's Physics.Raycast Documentation
Parameters
Parameters
ray
Returns
Parameters
ray
maxDistance
Returns
Parameters
Returns
Returns
Returns
Returns
Advance physics simulation by a specified time, useful for 'fast-forwarding' physics. Unity's Physics.Simulate Documentation
Parameters
step
Time to advance simulation by, in seconds.
Returns
Parameters
ray
radius
Parameters
Parameters
Parameters
ray
radius
Returns
Parameters
Returns
Parameters
Returns
Returns
Returns
Returns
Synchronize transform data used in physics simulation with GameObjects' actual transform data. Unity's Physics.SyncTransforms Documentation
Returns
Updated about 15 hours ago