Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
CharacterContactListener Class Reference

This class receives callbacks when a virtual character hits something. More...

#include <CharacterVirtual.h>

Public Member Functions

virtual ~CharacterContactListener ()=default
 Destructor. More...
 
virtual void OnAdjustBodyVelocity (const CharacterVirtual *inCharacter, const Body &inBody2, Vec3 &ioLinearVelocity, Vec3 &ioAngularVelocity)
 
virtual bool OnContactValidate (const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2)
 Checks if a character can collide with specified body. Return true if the contact is valid. More...
 
virtual void OnContactAdded (const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, CharacterContactSettings &ioSettings)
 
virtual void OnContactSolve (const CharacterVirtual *inCharacter, const BodyID &inBodyID2, const SubShapeID &inSubShapeID2, RVec3Arg inContactPosition, Vec3Arg inContactNormal, Vec3Arg inContactVelocity, const PhysicsMaterial *inContactMaterial, Vec3Arg inCharacterVelocity, Vec3 &ioNewCharacterVelocity)
 

Detailed Description

This class receives callbacks when a virtual character hits something.

Constructor & Destructor Documentation

◆ ~CharacterContactListener()

virtual CharacterContactListener::~CharacterContactListener ( )
virtualdefault

Destructor.

Member Function Documentation

◆ OnAdjustBodyVelocity()

virtual void CharacterContactListener::OnAdjustBodyVelocity ( const CharacterVirtual inCharacter,
const Body inBody2,
Vec3 ioLinearVelocity,
Vec3 ioAngularVelocity 
)
inlinevirtual

Callback to adjust the velocity of a body as seen by the character. Can be adjusted to e.g. implement a conveyor belt or an inertial dampener system of a sci-fi space ship. Note that inBody2 is locked during the callback so you can read its properties freely.

◆ OnContactAdded()

virtual void CharacterContactListener::OnContactAdded ( const CharacterVirtual inCharacter,
const BodyID inBodyID2,
const SubShapeID inSubShapeID2,
RVec3Arg  inContactPosition,
Vec3Arg  inContactNormal,
CharacterContactSettings ioSettings 
)
inlinevirtual

Called whenever the character collides with a body.

Parameters
inCharacterCharacter that is being solved
inBodyID2Body ID of body that is being hit
inSubShapeID2Sub shape ID of shape that is being hit
inContactPositionWorld space contact position
inContactNormalWorld space contact normal
ioSettingsSettings returned by the contact callback to indicate how the character should behave

◆ OnContactSolve()

virtual void CharacterContactListener::OnContactSolve ( const CharacterVirtual inCharacter,
const BodyID inBodyID2,
const SubShapeID inSubShapeID2,
RVec3Arg  inContactPosition,
Vec3Arg  inContactNormal,
Vec3Arg  inContactVelocity,
const PhysicsMaterial inContactMaterial,
Vec3Arg  inCharacterVelocity,
Vec3 ioNewCharacterVelocity 
)
inlinevirtual

Called whenever a contact is being used by the solver. Allows the listener to override the resulting character velocity (e.g. by preventing sliding along certain surfaces).

Parameters
inCharacterCharacter that is being solved
inBodyID2Body ID of body that is being hit
inSubShapeID2Sub shape ID of shape that is being hit
inContactPositionWorld space contact position
inContactNormalWorld space contact normal
inContactVelocityWorld space velocity of contact point (e.g. for a moving platform)
inContactMaterialMaterial of contact point
inCharacterVelocityWorld space velocity of the character prior to hitting this contact
ioNewCharacterVelocityContains the calculated world space velocity of the character after hitting this contact, this velocity slides along the surface of the contact. Can be modified by the listener to provide an alternative velocity.

◆ OnContactValidate()

virtual bool CharacterContactListener::OnContactValidate ( const CharacterVirtual inCharacter,
const BodyID inBodyID2,
const SubShapeID inSubShapeID2 
)
inlinevirtual

Checks if a character can collide with specified body. Return true if the contact is valid.


The documentation for this class was generated from the following file: