docs.unity3d.com
    Show / Hide Table of Contents

    Struct CollisionFilter

    Describes which other objects an object can collide with.

    Inherited Members
    ValueType.Equals(Object)
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.Physics
    Syntax
    public struct CollisionFilter : IEquatable<CollisionFilter>

    Fields

    BelongsTo

    A bit mask describing which layers this object belongs to.

    Declaration
    public uint BelongsTo
    Field Value
    Type Description
    UInt32

    CollidesWith

    A bit mask describing which layers this object can collide with.

    Declaration
    public uint CollidesWith
    Field Value
    Type Description
    UInt32

    Default

    (Immutable) A collision filter which wants to collide with everything.

    Declaration
    public static readonly CollisionFilter Default
    Field Value
    Type Description
    CollisionFilter

    GroupIndex

    An optional override for the bit mask checks. If the value in both objects is equal and positive, the objects always collide. If the value in both objects is equal and negative, the objects never collide.

    Declaration
    public int GroupIndex
    Field Value
    Type Description
    Int32

    Zero

    (Immutable) A collision filter which never collides with against anything (including Default).

    Declaration
    public static readonly CollisionFilter Zero
    Field Value
    Type Description
    CollisionFilter

    Properties

    IsEmpty

    Returns true if the filter cannot collide with anything, which likely means it was default constructed but not initialized.

    Declaration
    public readonly bool IsEmpty { get; }
    Property Value
    Type Description
    Boolean

    True if this object is empty, false if not.

    Methods

    CreateUnion(CollisionFilter, CollisionFilter)

    Return a union of two filters.

    Declaration
    public static CollisionFilter CreateUnion(CollisionFilter filterA, CollisionFilter filterB)
    Parameters
    Type Name Description
    CollisionFilter filterA

    The filter a.

    CollisionFilter filterB

    The filter b.

    Returns
    Type Description
    CollisionFilter

    The new union.

    Equals(CollisionFilter)

    Tests if this CollisionFilter is considered equal to another.

    Declaration
    public bool Equals(CollisionFilter other)
    Parameters
    Type Name Description
    CollisionFilter other

    The collision filter to compare to this object.

    Returns
    Type Description
    Boolean

    True if the objects are considered equal, false if they are not.

    Implements
    IEquatable<T>.Equals(T)

    GetHashCode()

    Calculates a hash code for this object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    A hash code for this object.

    Overrides
    ValueType.GetHashCode()

    IsCollisionEnabled(CollisionFilter, CollisionFilter)

    Return true if the given pair of filters want to collide with each other.

    Declaration
    public static bool IsCollisionEnabled(CollisionFilter filterA, CollisionFilter filterB)
    Parameters
    Type Name Description
    CollisionFilter filterA

    The filter a.

    CollisionFilter filterB

    The filter b.

    Returns
    Type Description
    Boolean

    True if the collision is enabled, false if not.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023