20. Contacts
When two Shapes are in contact, AGX Dynamics automatically generate contact points for these. The contact points are given to the AGX Dynamics solver during Simulation stepping.
The generation of contact points can to some extent be manipulated by the user.
Examples of this is using Collision Groups to disable contact generation between certain Shapes or setting the Contact Reduction Level in a Contact Material.
20.1. Contacts Rendering
Contacts rendering is possible by enabling the Draw Shape Contacts feature, which can be helpful for quicly inspecting contact behaviours between objects in a Simulation.
See Draw Shape Contacts for details on how to start and use Draw Shape Contacts.
For more control over contacts, for rendering or other operations, contact points can be accessed from Blueprint or C++, see Accessing Contact Points.
20.2. Accessing Contact Points
Below, examples of how to access contact points in Blueprints are shown. Accessing contact points from C++ is also supported.
To access contact points for a specific Shape, simply call the GetShapeContacts function on it.
Accessing and manually drawing contact points for a given Shape.
To access all contact points in the Simulation, call the GetShapeContacts on the AGX Simulation object.
Accessing and manually drawing all contact points in the Simulation.
20.3. Contact Event Listener
It is possible to listen for contact events emitted by AGX Dynamics while Step Forward is running. This is different from using the Get Shape Contacts function in that it happens during the step instead of after which means that contacts not seen by the solver, e.g. contacts involving Kinematic bodies, are included. Also, it is possible to modify the contacts, for example by altering depth or normal directions, or to disable contacts entirely.
Contact listening is available both as events on AGX Simulation and as overridable functions on the Contact Event Listener Component, which a Blueprint class can inherit from.
For the events on AGX Simulation to trigger Enable Global Contact Event Listener must be enbled in Project Settings > Plugins > AGX Dynamics > Simulation.
Enable or disable global contact event listeners from the Project Settings.
The following Blueprint Visual Script graph demonstrates how to set a surface velocity on each contact point at On Impact and remove the contact in the following time step, when On Contact is called.
Modifying contacts using contact events.
For more information on contact event listeners in AGX Dynamics see the Collision Events section of the AGX Dynamics user manual.