Struct PhysicsMaterial
Deterministic surface material coefficients used by contact response.
[MemoryPackable(GenerateType.Object)]
public readonly struct PhysicsMaterial : IEquatable<PhysicsMaterial>, IMemoryPackable<PhysicsMaterial>, IMemoryPackFormatterRegister
- Implements
-
IMemoryPackable<PhysicsMaterial>IMemoryPackFormatterRegister
- Inherited Members
Remarks
Static and dynamic friction are non-negative Coulomb coefficients. Restitution is the bounce coefficient in the inclusive range [0, 1]. Dynamic friction cannot exceed static friction.
Constructors
PhysicsMaterial(Fixed64, Fixed64, Fixed64, PhysicsMaterialCombine, PhysicsMaterialCombine)
Creates a deterministic surface material.
[JsonConstructor]
public PhysicsMaterial(Fixed64 staticFriction, Fixed64 dynamicFriction, Fixed64 restitution, PhysicsMaterialCombine frictionCombine = PhysicsMaterialCombine.GeometricMean, PhysicsMaterialCombine restitutionCombine = PhysicsMaterialCombine.Minimum)
Parameters
staticFrictionFixed64dynamicFrictionFixed64restitutionFixed64frictionCombinePhysicsMaterialCombinerestitutionCombinePhysicsMaterialCombine
Properties
Bouncy
A high-restitution surface that keeps the default friction values.
[JsonIgnore]
[MemoryPackIgnore]
public static PhysicsMaterial Bouncy { get; }
Property Value
Default
The release default surface: unit friction, half restitution, geometric friction combine, and minimum restitution combine.
[JsonIgnore]
[MemoryPackIgnore]
public static PhysicsMaterial Default { get; }
Property Value
DynamicFriction
Gets the friction coefficient used after tangential motion exceeds the static friction limit.
public Fixed64 DynamicFriction { get; }
Property Value
- Fixed64
FrictionCombine
Gets this surface's preferred combine policy for static and dynamic friction coefficients.
public PhysicsMaterialCombine FrictionCombine { get; }
Property Value
Frictionless
A surface with no contact friction and no restitution.
[JsonIgnore]
[MemoryPackIgnore]
public static PhysicsMaterial Frictionless { get; }
Property Value
Restitution
Gets the restitution coefficient. Zero removes closing velocity without bounce; one is fully elastic before the context restitution threshold is applied.
public Fixed64 Restitution { get; }
Property Value
- Fixed64
RestitutionCombine
Gets this surface's preferred combine policy for restitution.
public PhysicsMaterialCombine RestitutionCombine { get; }
Property Value
StaticFriction
Gets the friction coefficient used while tangential contact motion can be fully resisted by Coulomb static friction.
public Fixed64 StaticFriction { get; }
Property Value
- Fixed64
Methods
CombineFriction(PhysicsMaterial, PhysicsMaterial, out Fixed64, out Fixed64)
Resolves effective static and dynamic friction coefficients for a pair of contacting surfaces.
public static void CombineFriction(PhysicsMaterial left, PhysicsMaterial right, out Fixed64 staticFriction, out Fixed64 dynamicFriction)
Parameters
leftPhysicsMaterialrightPhysicsMaterialstaticFrictionFixed64dynamicFrictionFixed64
CombineRestitution(PhysicsMaterial, PhysicsMaterial)
Resolves the effective restitution coefficient for a pair of contacting surfaces.
public static Fixed64 CombineRestitution(PhysicsMaterial left, PhysicsMaterial right)
Parameters
leftPhysicsMaterialrightPhysicsMaterial
Returns
- Fixed64
CombineScalar(Fixed64, Fixed64, PhysicsMaterialCombine)
Combines two scalar coefficients with one explicit deterministic policy.
public static Fixed64 CombineScalar(Fixed64 left, Fixed64 right, PhysicsMaterialCombine policy)
Parameters
leftFixed64rightFixed64policyPhysicsMaterialCombine
Returns
- Fixed64
Equals(PhysicsMaterial)
public bool Equals(PhysicsMaterial other)
Parameters
otherPhysicsMaterial
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ResolveDominantPolicy(PhysicsMaterialCombine, PhysicsMaterialCombine)
Resolves the contact policy when two surfaces specify different combine policies. The order is deterministic and independent of collider order.
public static PhysicsMaterialCombine ResolveDominantPolicy(PhysicsMaterialCombine left, PhysicsMaterialCombine right)
Parameters
leftPhysicsMaterialCombinerightPhysicsMaterialCombine
Returns
Operators
operator ==(PhysicsMaterial, PhysicsMaterial)
Determines whether two materials have equal coefficients and combine policies.
public static bool operator ==(PhysicsMaterial left, PhysicsMaterial right)
Parameters
leftPhysicsMaterialrightPhysicsMaterial
Returns
operator !=(PhysicsMaterial, PhysicsMaterial)
Determines whether two materials differ in any coefficient or combine policy.
public static bool operator !=(PhysicsMaterial left, PhysicsMaterial right)
Parameters
leftPhysicsMaterialrightPhysicsMaterial