Description
The TraceBody
method in the PlayerController
class is used to trace the axis-aligned bounding box (AABB) of the player's body from one position to another within the scene. This method returns a SceneTraceResult
which contains information about the trace, such as whether it hit any objects, the position of the hit, and the normal of the surface hit.
Usage
To use the TraceBody
method, you need to provide the starting and ending positions as Vector3
objects, as well as the scale and height scale of the body. These parameters define the dimensions and movement path of the AABB being traced.
Example usage:
Vector3 startPosition = new Vector3(0, 0, 0);
Vector3 endPosition = new Vector3(10, 0, 0);
float scale = 1.0f;
float heightScale = 1.0f;
SceneTraceResult result = playerController.TraceBody(startPosition, endPosition, scale, heightScale);
if (result.Hit)
{
// Handle collision
Vector3 hitPosition = result.Position;
Vector3 hitNormal = result.Normal;
// Additional logic
}
Example
Vector3 startPosition = new Vector3(0, 0, 0);
Vector3 endPosition = new Vector3(10, 0, 0);
float scale = 1.0f;
float heightScale = 1.0f;
SceneTraceResult result = playerController.TraceBody(startPosition, endPosition, scale, heightScale);
if (result.Hit)
{
// Handle collision
Vector3 hitPosition = result.Position;
Vector3 hitNormal = result.Normal;
// Additional logic
}