Struct CollisionFilter
Describes which other objects an object can collide with.
Implements
Inherited Members
Namespace: Unity.Physics
Assembly: Unity.Physics.dll
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 |
---|---|
uint |
CollidesWith
A bit mask describing which layers this object can collide with.
Declaration
public uint CollidesWith
Field Value
Type | Description |
---|---|
uint |
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 |
---|---|
int |
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 bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool | 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 |
---|---|
bool | True if the objects are considered equal, false if they are not. |
GetHashCode()
Calculates a hash code for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | 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 |
---|---|
bool | True if the collision is enabled, false if not. |