[UE4 Marketplace] Prediction Shot Plugin Document
Marketplace URL
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.
- Optimized processing when the predicted position collides with a wall etc.
- Add SetAccuracy Node (Ability to change Accuracy at runtime)
- 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
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 |
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 |
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 |
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
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 |
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 |
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 |
Type | Name | Description |
---|---|---|
float | SmoothingFactor | Smoothing factor of EMA |
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 |
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) |
By implementing this interface and attaching to the {CharacterLinear, Linear} FCS component, you can calculate predicted shots with your own measurement method
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) |
By implementing this interface and attaching to the {CharacterCircular, Circular} FCS component, you can calculate predicted shots with your own measurement method
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) |