Struct CollisionFilter
Describes which other objects an object can collide with.
Inherited Members
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
GetHashCode()
Calculates a hash code for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for this object. |
Overrides
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. |