35 UPROPERTY(Replicated, BlueprintReadWrite, Category =
"State") FVector Velocity;
36 UPROPERTY(Replicated, BlueprintReadWrite, Category = "State") FRandomStream RandomStream;
38 UPROPERTY(BlueprintReadWrite, Category = "State")
bool OwnerSafe=false;
40 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Debug")
bool DebugEnabled;
41 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Debug")
float DebugTrailTime=1.0;
42 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Debug")
float DebugTrailWidth=0;
43 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Debug") FLinearColor DebugTrailColorFast = FLinearColor(0, 1, 0, 1);
44 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Debug") FLinearColor DebugTrailColorSlow = FLinearColor(1, 0, 0, 1);
45 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Debug")
bool DebugPooling;
47 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World") FVector Wind;
48 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "Select atmosphere model"))
EEBAtmosphereType AtmosphereType;
49 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World", meta = (ToolTip = "Air Density at sea level - in KG/m^3", ClampMin = "0"))
float SeaLevelAirDensity = 1.21;
50 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World", meta = (ToolTip = "in cm/s", ClampMin = "0"))
float SeaLevelSpeedOfSound = 34300;
51 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World", meta = (ToolTip = "Used for Density Curve atmosphere model")) UCurveFloat* AirDensityCurve;
52 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World")
bool SpeedOfSoundVariesWithAltitude = false;
53 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World") UCurveFloat* SpeedOfSoundCurve;
55 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World")
float WorldScale = 1.0;
56 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "Atmosphere pressure at 0,0,0 - in millibars", ClampMin = "0"))
float SeaLevelAirPressure = 1012.5f;
57 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "Atmosphere Temperature at 0,0,0 - in degrees C"))
float SeaLevelAirTemperature = 20.0f;
58 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "Temperature Decrease With Altitude, degrees per meter"))
float TemperatureLapseRate = 0.00649f;
59 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "Altitude at which temperature stops decreasing, in meters"))
float TropopauseAltitude = 11000.0f;
60 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "Specific Gas Constant, dry air = 287.058", ClampMin = "0"))
float SpecificGasConstant = 287.058;
61 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "World Origin
Location")) FVector WorldCenterLocation = FVector(0, 0, 0);
62 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "
Use spherical planet model to get altitude"))
bool SphericalAltitude = false;
63 UPROPERTY(BlueprintReadWrite, EditAnywhere, SaveGame, Category = "World", meta = (ToolTip = "Planet radius, in Unreal units", EditCondition = "SphericalAltitude", ClampMin = "0"))
float SeaLevelRadius = 637100000.0f;
65 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World")
bool OverrideGravity = false;
66 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "World") FVector Gravity = FVector(0,0,-980);
68 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Safe launch")
bool SafeLaunch = true;
69 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Safe launch", Meta = (EditCondition = "SafeLaunch"))
bool SafeLaunchIgnoreAttachParent = true;
70 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Safe launch", Meta = (EditCondition = "SafeLaunchIgnoreAttachParent"))
bool SafeLaunchIgnoreAllAttached = true;
71 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Safe launch", Meta = (EditCondition = "SafeLaunch", ClampMin = "0"))
float SafeDelay = 1.0;
72 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Safe launch", Meta = (EditCondition = "SafeLaunch")) TArray<AActor*> SafeLaunchIgnoredActors;
74 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Shotgun")
bool Shotgun=false;
75 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Shotgun", meta = (EditCondition = "
Shotgun"))
int ShotCount=10;
76 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Shotgun", meta = (EditCondition = "
Shotgun"))
float ShotSpread=0.01;
77 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Shotgun", meta = (EditCondition = "
Shotgun"))
float ShotVelocitySpread = 0.01;
79 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight")
float MuzzleVelocityMin = 100000.0;
80 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight")
float MuzzleVelocityMax = 100000.0;
81 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight", meta = (ToolTip = "Maximum bullet spread, in radians", ClampMin = "0"))
float Spread = 0.0f;
82 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight", meta = (ToolTip = "Spread bias, higher is more accurate on average", ClampMin = "0"))
float SpreadBias = 0.0f;
83 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight")
float Mass = 0.005;
84 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight")
float Diameter = 0.556;
85 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight")
float FormFactor = 1.0;
86 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Flight") UCurveFloat* MachDragCurve;
88 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float GrazingAngleExponent = 2.0;
89 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float MinPenetration = 10.0;
90 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float MaxPenetration = 20.0;
91 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float PenetrationNormalization = 0.5;
92 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float PenetrationNormalizationGrazing = 0.0;
93 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float PenetrationEntryAngleSpread = 0.1;
94 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float PenetrationExitAngleSpread = 0.1;
95 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float RicochetProbability = 0.1;
96 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float RicochetProbabilityGrazing = 1;
97 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float RicochetRestitution = 0.1;
98 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float RicochetFriction = 0.0;
99 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float RicochetSpread = 0.1;
100 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
bool SpeedControlsRicochetProbability = false;
101 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
bool AddImpulse = true;
102 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
float ImpulseMultiplier = 1.0;
106 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
bool MaterialDensityControlsPenetrationDepth = true;
107 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Impact")
bool MaterialRestitutionControlsRicochet = true;
109 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Replication")
bool ReliableReplication = false;
111 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Collision", meta = (ToolTip = "Allow components to collide, intended for use with trigger volumes. Do not use for actual collisions."))
bool AllowComponentCollisions = false;
112 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Collision") TEnumAsByte<ECollisionChannel> TraceChannel;
113 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Collision")
bool TraceComplex;
114 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Collision")
float CollisionMargin=1.0;
115 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Collision", meta = (ToolTip = "Bullets with lower velocity will automatically despawn on impact, never despawn if set to zero or negative"))
float DespawnVelocity=100.0f;
116 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "
Collision") TArray<AActor*> IgnoredActors;
118 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Simulation", meta = (ToolTip = "Spawned bullet performs first trace immediately, instead of waiting for next simulation step"))
bool DoFirstStepImmediately = true;
119 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Simulation", meta = (EditCondition = "DoFirstStepImmediately"))
bool RandomFirstStepDelta = true;
120 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Simulation")
bool FixedStep = false;
121 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Simulation", meta = (EditCondition = "FixedStep", ClampMin = "0"))
float FixedStepSeconds = 0.1;
122 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Simulation")
int MaxTracesPerStep = 8;
124 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Retrace")
bool Retrace = true;
125 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Retrace")
bool RetraceOnAnotherChannel = false;
126 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Retrace", meta=(EditCondition="RetraceOnAnotherChannel")) TEnumAsByte<ECollisionChannel> RetraceChannel;
128 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Rotation")
bool RotateActor = true;
129 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Rotation")
bool RotateRandomRoll = true;
131 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Pooling")
bool EnablePooling = true;
132 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Pooling")
int MaxPoolSize = 50;
135 virtual
void ApplyWorldOffset(const FVector& InOffset,
bool bWorldShift) override;
138 virtual
void BeginPlay() override;
141 virtual
void Tick(
float DeltaSeconds) override;
143 virtual
void LifeSpanExpired() override;
145 UFUNCTION(BlueprintCallable, Category = "EBBullet|Spawn")
146 static
void SpawnWithExactVelocity(TSubclassOf<class
AEBBullet> BulletClass, AActor* BulletOwner, APawn* BulletInstigator, FVector BulletLocation, FVector BulletVelocity);
148 UFUNCTION(BlueprintCallable, Category = "EBBullet|Spawn")
149 static
void Spawn(TSubclassOf<class
AEBBullet> BulletClass, AActor* BulletOwner, APawn* BulletInstigator, FVector BulletLocation, FVector BulletVelocity);
151 UFUNCTION(NetMulticast, Unreliable)
152 void VelocityChangeBroadcast(FVector_NetQuantize NewLocation, FVector NewVelocity);
153 UFUNCTION(NetMulticast, Reliable)
154 void VelocityChangeBroadcastReliable(FVector_NetQuantize NewLocation, FVector NewVelocity);
156 UFUNCTION(BlueprintAuthorityOnly, BlueprintNativeEvent, Category = "EBBullet|Impact")
157 void OnImpact(
bool Ricochet,
bool PassedThrough, FVector
Location, FVector IncomingVelocity, FVector
Normal, FVector ExitLocation, FVector ExitVelocity, FVector Impulse,
float PenetrationDepth, AActor* Actor, USceneComponent* Component, FName BoneName, UPhysicalMaterial* PhysMaterial, FHitResult HitResult);
159 UFUNCTION(BlueprintCosmetic, BlueprintNativeEvent, Category = "EBBullet|Impact")
160 void OnNetPredictedImpact(
bool Ricochet,
bool PassedThrough, FVector
Location, FVector IncomingVelocity, FVector
Normal, FVector ExitLocation, FVector ExitVelocity, FVector Impulse,
float PenetrationDepth, AActor* Actor, USceneComponent* Component, FName BoneName, UPhysicalMaterial* PhysMaterial, FHitResult HitResult);
162 UFUNCTION(BlueprintImplementableEvent, Category = "EBBullet|Impact")
163 void OnTrace(FVector StartLocation, FVector EndLocation);
165 UFUNCTION(BlueprintImplementableEvent, Category = "EBBullet|Remote")
166 void OnTrajectoryUpdateReceived(FVector
Location, FVector OldVelocity, FVector NewVelocity);
168 UFUNCTION(BlueprintNativeEvent, Category = "EBBullet|Activation")
169 void OnDeactivated();
171 UFUNCTION(BlueprintNativeEvent, Category = "EBBullet|Flight")FVector UpdateVelocity(UWorld* World, FVector
Location, FVector PreviousVelocity,
float DeltaTime) const;
172 UFUNCTION(BlueprintNativeEvent, Category = "EBBullet|World") FVector GetWind(UWorld* World, FVector
Location) const;
173 UFUNCTION(BlueprintNativeEvent, Category = "EBBullet|World")
float GetAirDensity(UWorld* World, FVector
Location) const;
174 UFUNCTION(BlueprintNativeEvent, Category = "EBBullet|World")
float GetSpeedOfSound(UWorld* World, FVector
Location) const;
175 UFUNCTION(BlueprintNativeEvent, Category = "EBBullet|World")
bool CollisionFilter(FHitResult HitResult) const;
178 UFUNCTION(BlueprintAuthorityOnly, BlueprintCallable, Category = "EBBullet|Pooling")
void Deactivate();
180 UFUNCTION(NetMulticast, Reliable)
181 void ReactivationBroadcast(FVector_NetQuantize NewLocation, FVector NewVelocity, AActor* BulletOwner, APawn* BulletInstigator);
182 UFUNCTION(NetMulticast, Reliable)
183 void DeactivationBroadcast();
186 static
AEBBullet* GetFromPool(UWorld* World, UClass* BulletClass);
187 static
AEBBullet* SpawnOrReactivate(UWorld* World, TSubclassOf<class
AEBBullet> BulletClass, const FTransform& Transform, FVector BulletVelocity, AActor* BulletOwner, APawn* BulletInstigator);
188 void DeactivateToPool();
190 void Step(
float DeltaTime);
192 float Trace(FVector start, FVector PreviousVelocity,
float delta, TEnumAsByte<ECollisionChannel> channel);
194 TArray<AActor*> GetAttachedActorsRecursive(AActor* Actor,uint16 Depth=0) const;
196 float PenetrationTrace(FVector start, FVector end, TWeakObjectPtr<UPrimitiveComponent,FWeakObjectPtr> comp,
EPenTraceType penType, TEnumAsByte<ECollisionChannel> channel, FVector &exitLoc, FVector &exitNormal);
198 inline
float GetCurveValue(const UCurveFloat* curve,
float in,
float deflt) const;
200 float AccumulatedDelta;
202 bool CanRetrace = false;
203 FVector LastTraceStart;
204 float LastTraceDelta;
205 FVector LastTraceVelocity;
206 FVector LastTracePrevVelocity;
210 FHitResult FilterHits(TArray<FHitResult> Results,
bool &hit) const;
211 TArray<AActor*>GetSafeLaunchIgnoredActors(AActor*
Owner) const;
213 float GetAltitude(UWorld* World, FVector
Location) const;
214 float GetAltitudePressure(
float AltitudeMeter) const;
215 float GetAltitudeTemperature(
float AltitudeMeter) const;
216 float GetAltitudeDensity(
float AltitudeMeter) const;
219 inline FLinearColor GetDebugColor(
float In)
const{
220 return FMath::Lerp(DebugTrailColorSlow, DebugTrailColorFast, In);