This component manages the movement of the projectile and detects collisions with objects.
Class Functions #
- Set Interpolated Component : Assigns the component that will be used for network interpolation/smoothing. It is expected that this is a component attached somewhere below the UpdatedComponent. When network updates use MoveInterpolationTarget() to move the UpdatedComponent, the interpolated component’s relative offset will be maintained and smoothed over the course of future component ticks. The current relative location and rotation of the component is saved as the target offset for future interpolation.
- Move Interpolation Target : Moves the UpdatedComponent, which is also the interpolation target for the interpolated component. If there is not interpolated component, this simply moves UpdatedComponent. Use this typically from PostNetReceiveLocationAndRotation() or similar from an Actor.
- Reset Interpolation : Resets interpolation so that interpolated component snaps back to the initial location/rotation without any additional offsets.
- Add Actor to Ignore List : Add an actor to be ignored by projectile.
- Remove Actor from Ignore List : Remove an actor from ignore list. It will no longer be ignored by the projectile.
- Get Ignore List : Get an array of ignored actors by this projectile. Warning! May contain automatically added actors such as the physics volume.
- Set Homing Target : If Target is valid, the projectile travels toward its target. Currently, the projectile does not take into account obstacles to calculate its path. Should be set when projectile is constructed or later.
- Clear Homing Target : Clear projectile homing target. Projectile continue its movement to the last direction calculated.
- Is Velocity Under Simulation Threshold : Returns true if velocity magnitude is less than Velocity Stop Simulating Threshold.
- Set Velocity in Local Space : Sets the velocity to the new value, rotated into Actor space.
- Stop Simulating : Clears the reference to UpdatedComponent, fires stop event (OnProjectileStop), and stops ticking (if bAutoUpdateTickRegistration is true).
- Is Interpolation Complete : Returns whether interpolation is complete because the target has been reached. True when interpolation is disabled.
Class Settings #
- Initial Speed : Initial speed of projectile. If greater than zero, this will override the initial Velocity value and instead treat Velocity as a direction.
- Max Speed : Limit on speed of projectile (0 means no limit).
- Rotation Follow Velocity : If true, this projectile will have its rotation updated each frame to match the direction of its velocity.
- Rotation Remains Vertical : If true, this projectile will have its rotation updated each frame to maintain the rotations Yaw only.
Projectile Feature #
- Impact Context Name : Impact Context used for projectile simulation (Contain some useful surface data) Use “Generic” if nothing is specified.
Object Crossing #
- Can Cross Object : Whether or not projectile can cross an object.
- Max Crossed Object Count : The maximum number of surfaces that the projectile can pass through in total. Leave to 0 to use default settings. Used primary for performance optimization.
- Max Random Crossing Deviation : Uses the shape of a cone to randomize the direction of the projectile after crossing object. Set the maximum angle of the cone. We recommend keeping this value low.
- Max Crossing Object Length : The max distance from impact point. Used by line trace to find out location. Used primary for performance optimization.
Ricochet #
- Can Ricochet : If true, projectile ricochet will be simulated. Set this to false to stop simulating on first impact.
- Allow Wide Ricochet : If true, allow projectile to wide ricochet. bWideRicochetDeflection in impact surface asset should be enabled as well.
- Max Ricochet Count : The maximum number of ricochet that the projectile can do. Leave to 0 to use default settings. Used primary for performance.
- Ricochet Max Incident Angle : This is the max angle from flat surface a projectile can ricochet.
- Random Ricochet Deviation : Enable this option to add randomness to the direction of the ricochet.
- Max Random Ricochet Deviation : Uses the shape of a cone to randomize the direction of the ricochet. Set the maximum angle of the cone. For now, keep this value low because it can cause “double ricochet issue”.
- Ricochet Angle Affects Friction : Controls the effects of friction on velocity parallel to the impact surface when ricochet.
- If true, friction will be modified based on the angle of impact, making friction higher for perpendicular impacts and lower for glancing impacts.
- If false, a ricochet will retain a proportion of tangential velocity equal to (1.0 – Friction), acting as a “horizontal restitution”.
- Bounciness : Percentage of velocity maintained after the ricochet in the direction of the normal of impact (coefficient of restitution). 1.0 = no velocity lost, 0.0 = no bounce. Ignored if bCanRicochet is false.
- Friction : Coefficient of friction, affects the percentage of velocity maintained after the ricochet in the direction tangent to the normal of impact. Normal range is [0,1] : 0.0 = no friction, 1.0+ = very high friction. Ignored if bCanRicochet or bRicochetAngleAffectsFriction are false.
- Min Friction Fraction : When ricochet angle affects friction, apply at least this fraction of normal friction. Helps consistently slow objects sliding or rolling along surfaces or in valleys when the usual friction amount would take a very long time to settle.
Simulation #
- Velocity Stop Simulation Threshold : If velocity is below this threshold after an impact, stops simulating and triggers the OnProjectileStop event.
- Simulate Physics After Impact : If true, use physics to simulate the movement, otherwise the projectile remains stuck in the air or on the surface.
- Projectile Gravity Scale : Custom gravity scale for this projectile. Set to 0 for no gravity.
- Projectile Hardness : Hardness of projectile. Used for surface ricochet, object crossing and fragmentation. 0.0 (soft) to 1.0 (hard).
- Buoyancy : Buoyancy of Updated Component in fluid. Affect velocity calculation. 0.0=sinks as fast as in air, 1.0=neutral buoyancy.
Collision #
- Trace Complex : If true, collision test use complex collision instead of simple collision. Warning! Can be expensive.
- Collision Trace : Choose trace type you want to detect projectile collision in world.
- Sphere Radius : [Only is Sphere Collision Trace] Radius of sphere.
- Force SubStepping : If true, forces sub-stepping to break up movement into discrete smaller steps to improve accuracy of the trajectory. Objects that move in a straight line typically do not need to set this, as movement always uses continuous collision detection (sweeps) so collision is not missed. Sub-stepping is automatically enabled when under the effects of gravity or when homing towards a target.
- Max simulation Time Step : Max time delta for each discrete simulation step. Lowering this value can address precision issues with fast-moving objects or complex collision scenarios, at the cost of performance. WARNING: if (MaxSimulationTimeStep * MaxSimulationIterations) is too low for the min framerate, the last simulation step may exceed MaxSimulationTimeStep to complete the simulation.
- Max simulation iterations : Max number of iterations used for each discrete simulation step. Increasing this value can address precision issues with fast-moving objects or complex collision scenarios, at the cost of performance. WARNING: if (MaxSimulationTimeStep * MaxSimulationIterations) is too low for the min framerate, the last simulation step may exceed MaxSimulationTimeStep to complete the simulation.
Network Optimization #
- Interp Movement : If true and there is an interpolated component set, location (and optionally rotation) interpolation is enabled which allows the interpolated object to smooth uneven updates of the UpdatedComponent’s location (usually to smooth network updates). This requires using SetInterpolatedComponent() to indicate the visual component that lags behind the collision, and using MoveInterpolationTarget() when the new target location/rotation is received (usually on a network update).
- Interp Location Time : “Time” over which most of the location interpolation occurs, when the UpdatedComponent (target) moves ahead of the interpolated component. Since the implementation uses exponential lagged smoothing, this is a rough time value and experimentation should inform a final result. A value of zero is effectively instantaneous interpolation.
- Interp Location Max Lag Distance : Max distance behind UpdatedComponent which the interpolated component is allowed to lag.
- Interp Location Snap To Target Distance : Max distance behind UpdatedComponent beyond which the interpolated component is snapped to the target location instead. For instance if the target teleports this far beyond the interpolated component, the interpolation is snapped to match the target.
- Interp Rotation : If true and there is an interpolated component set, rotation interpolation is enabled which allows the interpolated object to smooth uneven updates of the UpdatedComponent’s rotation (usually to smooth network updates). Rotation interpolation is only applied if bInterpMovement is also enabled.
- Interp Rotation Time : “Time” over which most of the rotation interpolation occurs, when the UpdatedComponent (target) moves ahead of the interpolated component. Since the implementation uses exponential lagged smoothing, this is a rough time value and experimentation should inform a final result. A value of zero is effectively instantaneous interpolation.
Debug #
- Draw Debug Life Time : Debug display duration.
- Draw Projectile Position : Draws a sphere and a directional arrow to display the projectile’s position during the simulation.
- Draw Trajectory : Draws the trajectory of projectile during the simulation.
- Draw Impact Position : Draws a point on impact (Projectile Stop)
- Draw Impact Direction : Draws a directional arrow to display the projectile impact direction.
- Draw Ricochet Position : Draws a point on ricochet impact position.
- Draw Ricochet Direction : Draws a directional arrow to display the exit direction of the ricochet
- Draw Start Object Crossing Location : Draws a point on impact position.
- Draw End Object Crossing Location : Draws a point on projectile exit position.
- Draw Object Crossing Projectile Deviation : Draws a directional arrow to display the projectile trajectory deviation.
Event #
- On Projectile Ricochet : Called when projectile ricochet on surface.
- On Projectile Begin Crossing Object : Called when the projectile passes through a surface.
- On Projectile End Crossing Object : Called when the projectile leaves a surface it has just crossed.
- On Projectile Stop : Called when projectile has come to a stop (velocity is below simulation threshold, bounces are disabled, or it is forcibly stopped).
- On Physics Volume Changed : Called when projectile enters in new physics volume.