PEB Trajectory Predictor stands for Physics-Engine-Based Trajectory Predictor. It invokes physics engine to simulate future frames and thus gives accurate prediction. It can predict bounces, it is compatible with air drag, angular drag, and physics materials.
PEB Trajectory Predictor is designed with performance in mind, with appropriate settings it can run smoothly on low-end devices.
Here's the PEB Trajectory Predictor component:
Line: The Line Renderer. If you use the prefab "PEB Trajectory Predictor.prefab" from "Blobcreate/Projectile Toolkit/Prefabs", it's been already set.
Simulatee: The Rigidbody to be simulated.
Obstacles: All the colliders to be simulated. If you have a bunch of GameObjects with collider on each of them that are grouped in one parent GameObject, make sure to drag each of them into the Obstacles field instead of the parent.
Update Obstacle Transforms: Turn this on for auto re-simulation, so that whenever any of the colliders moves, rotates, or scales, the prediction gets re-simulated.
Total Iterations: The total number of physics steps to simulate.
Max Iterations Every Frame: The max physics steps to simulate during one frame. This allocates physics simulation into several frames, thus optimizes the performance.
Simulation Timestep: The timestep of simulation. To get accurate prediction result, this should be the same as Fixed Timestep value in the project settings.
Launch Velocity: The launch velocity to be applied to the simulation.
Line Lerp Factor: Controls how smoothly the line is updated.
T Sync: Prevents the line from tearing (effective when Max Iterations Every Frame is smaller than Total Iterations).
The API of PEB Trajectory Predictor enables you to switch Simulatee
and add/remove obstacles (colliders) during runtime.
The launch velocity to be applied to the simulation.
public Vector3 LaunchVelocity
If you have any moving colliders, set this to true for auto re-simulation.
xxxxxxxxxx
public bool UpdateObstacleTransforms
Controls how smoothly the line is updated. The value should be in the range of 0f (exclusive) to 1f (inclusive). The smaller the value, the smoother the line updates.
xxxxxxxxxx
public float LineLerpFactor
Set to true to prevent the line from tearing (effective when Max Iterations Every Frame is smaller than Total Iterations).
xxxxxxxxxx
public bool TSync
The Rigidbody to be simulated.
xxxxxxxxxx
public Rigidbody Simulatee
Tells the PEB Trajectory Predictor to do one round of simulation and render the line accordingly.
xxxxxxxxxx
public void SimulateAndRender()
Adds a collider to the simulation context.
xxxxxxxxxx
public void AddObstacle(Transform obstacle)
Removes a collider from the simulation context.
xxxxxxxxxx
public void RemoveObstacle(Transform obstacle)