• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Services

    Edit

    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.

    Properties

    Control the global gravity in the physics simulation, defaulting to Earth's gravity.

    Define the minimum distance between colliders for them to be considered in contact.

    Set the velocity threshold below which GameObjects are considered static or immobile.

    Determine whether physics queries interact with trigger colliders.

    Decide if physics queries should detect hits on collider backfaces.

    Specify the minimum collision velocity for an object to bounce.

    Methods

    Refer to Unity's documentation for information on maximum depenetration velocity.

    Refer to Unity's documentation for information on solver iterations.

    Refer to Unity's documentation for information on solver velocity iterations.

    Refer to Unity's documentation for information on maximum angular speed.

    Refer to Unity's documentation for information on improved patch friction.

    Refer to Unity's documentation for information on collision callbacks invocation.

    Refer to Unity's documentation for information on automatic transforms synchronization.

    Refer to Unity's documentation for information on reusing collision callbacks.

    Refer to Unity's documentation for information on inter-collision distance.

    Refer to Unity's documentation for information on inter-collision stiffness.

    Refer to Unity's documentation for information on inter-collision settings toggle.

    clothGravity

    DataType.Vector3

    Refer to Unity's documentation for information on cloth gravity.

    Refer to Unity's documentation for information on the Ignore Raycast layer.

    Refer to Unity's documentation for information on default raycast layers.

    AllLayers

    number

    Refer to Unity's documentation for information on all layers.

    Trace a path in 3D space to detect colliders, useful for implementing bullet paths or line-of-sight features.

    Parameters

    ray
    Ray

    Defines the origin and direction of the ray.

    maxDistance

    number

    The maximum distance to check for collisions.

    layerMask

    number

    LayerMask to selectively ignore colliders.

    Returns

    RaycastHit)

    Returns true if any collider is hit, with collision details.

    Find all colliders touching or inside an imaginary sphere, useful for area damage or proximity checks.

    Parameters

    position
    Vector3

    Sphere center.

    radius

    number

    Sphere radius.

    layerMask

    number

    LayerMask to selectively ignore colliders.

    Returns

    Collider[]

    Array of colliders within the sphere.

    Prevent physics engine from processing collisions between two specified colliders.

    Parameters

    collider1
    Collider

    First collider.

    collider2
    Collider

    Second collider.

    ignore

    boolean

    Whether to ignore collisions.

    Returns

    void

    Does not return a value.

    Make physics engine ignore all collisions between colliders in two specified layers.

    Parameters

    layer1

    number

    First layer ID.

    layer2

    number

    Second layer ID.

    ignore

    boolean

    Whether to ignore collisions.

    Returns

    void

    Does not return a value.

    Check if collisions between any colliders in two layers are ignored.

    Parameters

    layer1

    number

    First layer ID.

    layer2

    number

    Second layer ID.

    Returns

    boolean

    True if collisions are ignored, false otherwise.

    Check if collisions between two specific colliders are ignored.

    Parameters

    collider1
    Collider

    First collider.

    collider2
    Collider

    Second collider.

    Returns

    boolean

    True if collisions are ignored, false otherwise.

    Advance physics simulation by a specified time, useful for 'fast-forwarding' physics.

    Parameters

    step

    number

    Time to advance simulation by, in seconds.

    Returns

    void

    Does not return a value.

    Synchronize transform data used in physics simulation with GameObjects' actual transform data.

    Returns

    void

    Does not return a value.

    Calculate the closest point to a given position on a collider's surface.

    Parameters

    point
    Vector3

    Position to check against.

    collider
    Collider

    Collider to check.

    position
    Vector3

    Collider's position.

    rotation
    Quaternion

    Collider's rotation.

    Returns

    Vector3

    Closest point on the collider.

    Force a rebuild of the tree for broad-phase collision detection after static collider movements.

    Parameters

    worldBounds
    Bounds

    New world boundaries for the physics simulation.

    subdivisions

    number

    Number of subdivisions in the broadphase tree.

    Returns

    void

    Does not return a value.

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.