PhysX World Programming Notes - Lumberyard User Guide

PhysX World Programming Notes

Open 3D Engine (O3DE), the successor to Lumberyard, is now available in Developer Preview. Download O3DE or visit the AWS Game Tech blog, O3DE Discord, or O3DE GitHub to learn more. The Lumberyard forums have been deprecated. You may view past forum discussions in the archive.

For physics objects to be simulated, they must exist inside a world. Multiple worlds can have uses like the following:

  • To simulate the result of an action in the first world. For example, the second world might show what a tower of blocks might look like five seconds from now if it were knocked over in the first world.

  • To simulate a subset of objects that you don't want to interact with the rest of the world. For example, you could simulate the movement of objects attached to a player's belt.

  • To overcome hardware or software limits on a single large world. By tiling the single world into multiple smaller worlds and moving objects among them, you can create the illusion of a single large world.

The PhysX gem automatically creates a world inside ActionGame with the default ID of AZPhysicalWorld. By default, all objects are added to this world and simulated each frame. You can find the source code in the following directory: lumberyard_version\dev\Gems\CryLegacy\Code\Source\CryAction\ActionGame.*)

World ID

Every world created in the PhysX gem is addressable by an ID of type AZ::Crc32. Use this ID to address the WorldRequestBus.

If you have a single world in your game, you can use BroadcastResult to invoke WorldRequestBus, as in the following example:

// Single world setup RayCastHit choose; WorldRequestBus::BroadcastResult(choose, &WorldRequests::RayCast, request);

If you have a multi-world game, use EventResult and pass in the world ID, as in the following example:

// Multiple world setup RayCastHit choose; WorldRequestBus::EventResult(choose, AZ_CRC("AZPhysicalWorld"), &WorldRequests::RayCast, request);

If your game creates multiple worlds, it must manage the objects that are added into those worlds.

Step Constants

You can configure step constants for Physics::WorldSettings when PhysXWorld is created. For more information, see World Configuration.