[UE4 Marketplace] PredictionShotPlugin
[UE4 Marketplace] Prediction Shot Plugin Document
Marketplace URL
Tutorial
Basic Tutorial
Advanced Tutorial
When combining linear movement and circular movement, implement as follows.
- Build Linear FCS and Circular FCS by referring to the basic tutorial.
- Use the GetAngularVelocity function from the Observer property of the CircularFCS component to get the angular velocity (rad)
- Switch between Linear FCS and Circular FCS using the obtained angular velocity
- Please set the reference value for switching by yourself.
Changelog
Version 1.2
- Optimized processing when the predicted position collides with a wall etc.
- Add SetAccuracy Node (Ability to change Accuracy at runtime)
Version 1.1
- Add PredictPos function to calculate predicted position
- Add HighArc option to shoot projectiles such as grenades at a higher angle
- Improve accuracy of prediction calculation during circular movement
- BugFix prediction calculation during counterclockwise circular movement
Correspondence table of FCSComponent and MeasurerComponent
Measurer components that can be attached per FCS component are different
FCS Component | Mesurer Component |
---|---|
LinearFCS | {SMA, EMA} VelocityMeasurer |
CircularFCS | {SMA, EMA} AngularMeasurer |
CharacterLinearFCS | {SMA, EMA} VelocityMeasurer |
CharacterCircularFCS | {SMA, EMA} AngularMeasurer |
Blueprint API Reference
{Linear, CharacterLinear} FCS SceneComponent
Variables
Type | Name | Description |
---|---|---|
int32 | Accuracy | Accuracy of prediction calculation |
float | ObserverTickInterval | Observe the target at the interval |
ECollisionChannel | TraceChannel | Trace channel for measuring the height of the landing point |
float | OffsetFromCollisionSurface | Offset value when the predicted point collides with the surface (Default = 50) |
IVelocityObservable | Observer | Object implementing IVelocityObservable |
Functions
Return Type | Name | Description |
---|---|---|
FRotator | Prediction( const float BulletSpeed, const float BulletGravityScale, const float TargetGravityScale, const FVector& From, const FVector& To, const bool bHighArc ) |
Calculate predicted shooting direction BulletGravityScale - Set the value of GravityScale set for the bullet to be shot TargetGravityScale - Set the value of GravityScale set for Target |
FVector | PredictPos( const float BulletSpeed, const float BulletGravityScale, const float TargetGravityScale, const FVector& From, const FVector& To, const bool bHighArc ) |
Calculate predicted position BulletGravityScale - Set the value of GravityScale set for the bullet to be shot TargetGravityScale - Set the value of GravityScale set for Target |
{Circular, CharacterCircular} FCS SceneComponent
If Character’s AirControl value is fairly low, CharacterLinearFCS may be used during jumping
(When the AirControl value is low, it is almost linear movement during jumping)
How to use CharacterLinearFCS and CharacterCircularFCS together → Tutorial Video
Variables
Type | Name | Description |
---|---|---|
int32 | Accuracy | Accuracy of prediction calculation |
float | ObserverTickInterval | Observe the target at the interval |
ECollisionChannel | TraceChannel | Trace channel for measuring the height of the landing point |
float | OffsetFromCollisionSurface | Offset value when the predicted point collides with the surface (Default = 50) |
IAngularObservable | Observer | Object implementing IAngularObservable |
Functions
Return Type | Name | Description |
---|---|---|
FRotator | Prediction( const float BulletSpeed, const float BulletGravityScale, const float TargetGravityScale, const FVector& From, const FVector& To, const bool bHighArc ) |
Calculate predicted shooting direction BulletGravityScale - Set the value of GravityScale set for the bullet to be shot TargetGravityScale - Set the value of GravityScale set for Target |
FVector | PredictPos( const float BulletSpeed, const float BulletGravityScale, const float TargetGravityScale, const FVector& From, const FVector& To, const bool bHighArc ) |
Calculate predicted position BulletGravityScale - Set the value of GravityScale set for the bullet to be shot TargetGravityScale - Set the value of GravityScale set for Target |
SMA {Velocity, Angular} Measurer SceneComponent
Variables
Type | Name | Description |
---|---|---|
int32 | NumOfFrames | Number of frames to be recorded by SMA |
int32 | CurrentIndex | Index representing the latest data |
TArray<float> | {Velocity, Angular} RecordingArray | Recording array |
EMA {Velocity, Angular} Measurer SceneComponent
Variables
Type | Name | Description |
---|---|---|
float | SmoothingFactor | Smoothing factor of EMA |
VelocityObservable Interface
Functions
Return Type | Name | Description |
---|---|---|
void | SetTarget( AActor* Target ) |
Set target |
AActor* | GetTarget() | Get target |
float | GetZVelocity() | Get speed in the Z direction when moving on a slope or the like (Character only) |
float | GetZAcceleration() | Get acceleration in the Z direction when moving on a slope or the like (Character only) |
float | GetJumpVelocity() | Get speed in the Z direction when jumping (Character only) |
float | GetVelocity() | Get velocity |
float | GetAcceleration() | Get acceleration |
AngularObservable Interface
Functions
Return Type | Name | Description |
---|---|---|
void | SetTarget( AActor* Target ) |
Set target |
AActor* | GetTarget() | Get target |
float | GetZVelocity() | Get speed in the Z direction when moving on a slope or the like (Character only) |
float | GetZAcceleration() | Get acceleration in the Z direction when moving on a slope or the like (Character only) |
float | GetJumpVelocity() | Get speed in the Z direction when jumping (Character only) |
float | GetAngularVelocity() | Get angular velocity (radian) |
float | GetAngularAcceleration() | Get angular acceleration (radian) |
TArray<FVector> | GetLocations() | Prev 3 locations (Index 0 -> the oldest position, Index 2 -> Newest position) |
VelocityMeasurable Interface
By implementing this interface and attaching to the {CharacterLinear, Linear} FCS component, you can calculate predicted shots with your own measurement method
Functions
Return Type | Name | Description |
---|---|---|
void | Reset( const AActor* const Target ) |
Reset the measurement |
void | SetFlyingMode( const bool bIsFlyingMode ) |
False if attached to CharacterFCS, true is passed otherwise |
bool | Measure( const AActor* const Target, float& OutVelocity, float& OutAcceleration, float& OutZVelocity, float& OutZAcceleration, float& OutJumpVelocity ) |
Measure the target (The return value is a dummy parameter) |
AngularMeasurable Interface
By implementing this interface and attaching to the {CharacterCircular, Circular} FCS component, you can calculate predicted shots with your own measurement method
Functions
Return Type | Name | Description |
---|---|---|
void | Reset( const AActor* const Target ) |
Reset the measurement |
void | SetFlyingMode( const bool bIsFlyingMode ) |
False if attached to CharacterFCS, true is passed otherwise |
bool | Measure( const AActor* const Target, float& OutAngularVelocity, float& OutAngularAcceleration, float& OutZVelocity, float& OutZAcceleration, float& OutJumpVelocity, TArray<FVector>& OutLocations, int32& OutStartIndex ) |
Measure the target (The return value is a dummy parameter) |