PhysX Simulated Bodies

AzPhysics::SimulatedBody is a base type from which many PhysX components inherit:

The interface for AzPhysics::SimulatedBody includes various common operations such as:

  • Handling collision and trigger events
  • Getting the Entity Id for the Entity to which the Simulated Body is attached
  • Getting the Entity Transform
  • Getting the Entity AABB
  • Performing a raycast against a particular Simulated Body

This functionality is also exposed via the SimulatedBodyComponentRequestsBus.


A Simulated Body raycast query tests whether a line segment directed from a specified point along a specified direction intersects with the Simulated Body (and only that body). Only the closest hit (if any) will be returned. It is also possible to perform PhysX Scene Queries which query against all the physics geometry in a scene.

A raycast query is specified using an AzPhysics::RayCastRequest.

RayCastRequest Properties

m_distanceMaximum distance along the ray to test for intersections.
m_startWorld space point where the ray starts.
m_directionDirection to cast the ray. This vector must be normalised.
m_hitFlagsFlags used to request particular hit fields to be returned, or indicate which hit fields are valid in a return value.
m_filterCallbackThis property is ignored by Simulated Body raycast queries.
m_reportMultipleHitsThis property is ignored by Simulated Body raycast queries, as only the closest hit will be returned.
m_maxResultsThis property is ignored by Simulated Body raycast queries, as only the closest hit will be returned.
m_collisionGroupSpecifies which layers to test against. Use this to test only against specific layers.
m_queryTypeThis property is ignored by Simulated Body raycast queries.

Example (C++)

AzPhysics::RayCastRequest request;
request.m_start = AZ::Vector3(-100.0f, 0.0f, 0.0f);
request.m_direction = AZ::Vector3(1.0f, 0.0f, 0.0f);
request.m_distance = 200.0f;

AzPhysics::SceneQueryHit hit;
AzPhysics::SimulatedBodyComponentRequestsBus::EventResult(hit, entityId, &AzPhysics::SimulatedBodyComponentRequests::RayCast, request);

Example (Lua)

request = RayCastRequest()
request.Start = Vector3(5.0, 0.0, 5.0)
request.Direction = Vector3(0.0, 0.0, -1.0)
request.Distance = 10.0
hit = SimulatedBodyComponentRequestBus.Event.RayCast(entityId, request)

Script Canvas

The Raycast (Single Body) node can be used in Script Canvas to perform Simulated Body raycast queries.

Copyright © 2022 Open 3D Engine Contributors

Documentation Distributed under CC BY 4.0.
For our trademark, privacy and antitrust policies, code of conduct, and terms of use, please click the applicable link below or see

The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Policy page.