This document is about: QUANTUM 3
SWITCH TO

2.5D Physics

Introduction

When using 2.5D Physics it is possible to add Height (or thickness) while still benefiting from most performance advantages available in the 2D physics engine.
N.B.: Use Vertical Transform is a field (enabled by default) that can be toggled in the SimulationConfig asset's Physics settings.

2.5D Physics with Vertical Data

StaticCollider2D can have 'thickness' in the 3rd dimension using Quantum's 2.5D physics; simply set the Height:

Adding Height to a Static Collider
Adding Height to a Static Collider.

For Entities, just add the Transform2DVertical component and set its Height and Position Offset. On a Quantum XZ-oriented game, this adds height on the Y axis, for example.
N.B.: Transform2DVertical requires the Transform2D component.

C#

    var transform2dVertical = new Transform2DVertical();
    transform2dVertical.Height = FP._1;
    transform2dVertical.Position = FP._1;
    
    f.Set(entity, transform2dVertical);
Adding Height to an Entity Prototype
Adding Height to an Entity Prototype.

If entities or statics have a 3rd dimension, the physics engine will take into consideration when solving collisions. This allows for 'aerial' entities to fly over 'ground-based' ones, etc.

Physics Engine Implications

Entity Separation

Important: When a collision is detected, the collision solver does not use the extra dimension information. This can result in entity bounce when separation is performed on the basic 2D plane of the physics engine.

It is possible to simulate 3-dimensional gravity by manually applying speed and forces directly on Transform2DVertical.Position. The physics engine will use that information only for collision detection though.

Raycast and Overlaps

These functions are by default all flat and only execute on the 2D plane. To take advantage of 2.5D, use the overloaded version that takes the height and vertical offset as parameters.

Back to top