# AGX Physics

{% hint style="warning" %}
AGX Dynamics for Unity is not part of the realvirtual.io delivery installation itself. AGX Dynamics for Unity is sold and distributed by [Algoryx](https://www.algoryx.se/).
{% endhint %}

As of realvirtual.io 2021.02, realvirtual.io also supports [AGX Dynamics for Unity](https://www.algoryx.se/agx-unity/). AGX is a commercial and optional high quality physics simulation that can simulate complex dynamics.

AGX Dynamics for Unity completely replaces the built-in game physics in Unity and allows you to use real physics, measure real forces and expect realistic results. For more information, please visit the [AGX Dynamics Website](https://www.algoryx.se/agx-unity/).

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-a71827ef792d70d4bab0dfadaf5899188b714488%2Falgoryx.gif?alt=media" alt=""><figcaption><p>Multi contact points on conveyor example based on AGX</p></figcaption></figure>

{% embed url="<https://youtu.be/ZGntCy16Wlk>" %}
Flexible cables and parts based on AGX physics engine
{% endembed %}

With AGX it is possible to simulate processes in engineering quality. The main advantage is that it is possible to measure real forces and detect multiple contact points between bodies. This allows, for example, very detailed conveyor simulations, where it is also possible to simulate the behavior when a part is on several different conveyors at the same time.

## Installation

To use AGX Dynamics for Unity together with realvirtual.io you also need to install the AGX Dynamics for Unity plugin. Please check the AGX documenation for more informationon about the installation: <https://us.download.algoryx.se/AGXUnity/documentation/current/getting_started.html#installing-the-plugin>

> A license key is needed for using AGX Dynamics for Unity. Please check the [AGX Dynamics Website](https://www.algoryx.se/agx-unity/) for more information regarding trial and licensing of AGX.

After installation of the AGX Unity plugin you need to activate it by selecting `File > Build Settings > Player > Script Compilation`.\
Here you need to add the Scripting Define Symbol `REALVIRTUAL_AGX`

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-cd68c84ec17f835319e8c1492608b9eb90b6967f%2Fagx-compilerdefines.png?alt=media" alt=""><figcaption><p>Scripting Define symbol for AGX Physics engine</p></figcaption></figure>

## realvirtual.io AGX support

Realvirtual.io does not automatically add AGX physics components to Gameobjects, as is sometimes the case with standard realvirtual.io components. You must add all the required AGX components manually, as described below.

{% hint style="info" %}
AGX and Unity Physics run in parallel in a scene. It is possible to simulate some parts of the scene with Unity PhysX and other parts with the AGX engine but you are not allowed to put an AGX and a Unity RigidBody in parallel on one Gameobject.
{% endhint %}

### Source and MU

To enable the AGX within the source `Use AGX Physics` needs to be turned on in the source.

{% hint style="info" %}
If the AGX specific properties like `Use AGX Physics` are not visible within the Source please check if the `GAME4AUTOMAION_AGX`compiler define is added to the Player settings like described above.
{% endhint %}

\
\\

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-87f49b5b78b377b5070cdc5bece8d7f3645d444b%2Fagx-sourceenable.png?alt=media" alt=""><figcaption><p>Use AGX in Source</p></figcaption></figure>

Additionally all MUs need to have a `AGX Shape Collider` (e.g. a Box Collider) and a AGX `RigidBody` added to it. Please check the AGX Unity Plugin documentation (<https://us.download.algoryx.se/AGXUnity/documentation/current>) for more information about these components.

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-671ba70f359d5e646821aec9767ada045efc4ee2%2Fagx-sourcecomponents.png?alt=media" alt=""><figcaption><p>AGX Collider and Rigidbody on Sourc</p></figcaption></figure>

### Drive

realvirtual.io [Drives ](#drive)can move mechanical axes. Axes are defined within AGX by `Contraint` for example with the Type `Hinge`. It is necessary to turn on the `Lock` Controller within the constraint. The Drive itself needs to be turned to `Virtual` (because the direction is defined by the AGX Constraint itself).

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-3d2b2dda07bc88899633fc65e4e0580f3e4987d3%2Fagx-drive.png?alt=media" alt=""><figcaption><p>Drive with AGX physics</p></figcaption></figure>

### Transportsurface

Conveyors are modeled within realvirtual.io with [Drives](https://game4automation.com/documentation/current/drive.html) connected to [Transportsurfaces](https://game4automation.com/documentation/current/transportsurface.html). This remains the same. On the [TransportSurface ](#transportsurface)`Use AGX Physics` needs to be turned on:

\\

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-c589e6ca0a565a2c3dcdbdcf68b1b304181e52f5%2Fagx-transportsurface.png?alt=media" alt=""><figcaption><p>Transportsurface with AGX physics</p></figcaption></figure>

The main advantage of the AGX Transportsurface is, that one [MU ](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit)can touch multiple Transportsurfaces and the resulting movement of the MU is calculated exactly. With the Unity PhysX engine only one contact point is calculated, what means that an [MU ](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit)never touches multiple Transportsurface, which is a disadvantage for very detailed simulations.

### Sink

Sinks must detect the parts to be destroyed. Use `AGX Physics` must be enabled and an AGX Box Collider must be added to the sink.

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-2d04ca8710d94386ddc98af5722d4f861ae2f4d2%2Fagx-sink.png?alt=media" alt=""><figcaption><p>Sink with AGX physics</p></figcaption></figure>

### Sensors

You can also use Raycast-based sensors with AGX physics. It is necessary to add a standard Unity Collider to your MUs on the layer `g4a SensorMU`.

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-162e0b311a963ab7efa2d45405ac133bd3bd3c5a%2Fagx-sensor.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Do not add a RigidBody to your MUs as this would violate the AGX Physics Engine. Please make sure that raycasts are used in all sensors that need to detect AGX based MUs. realvirtual.io collider based sensors are not possible in combination with AGX Physics Engine.\
\
The sensor raycast setting (see also [Sensor](https://game4automation.com/documentation/current/sensor.html)).\\
{% endhint %}

<figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-aa21d689e58be21d680269178ff12e0e859090f2%2Fagx-sensorraycast.png?alt=media" alt=""><figcaption><p>Use raycast based sensors with AGX Physics engine</p></figcaption></figure>

© 2025 realvirtual GmbH [https://realvirtual.io](https://realvirtual.io/) - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
