Fix retrace OwnerSafe bug and restore debug trace colors
Save and restore OwnerSafe state during retrace to prevent the bullet from hitting the owner's actors when replaying a previous trace where OwnerSafe was true. Also fix debug DrawDebugLine in Trace.cpp to use proper velocity-based colors instead of hardcoded values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9b9c5254db
commit
669b65a30f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -64,6 +64,8 @@ void AEBBullet::Step(float DeltaTime) {
|
|||||||
|
|
||||||
if (Retrace && CanRetrace) {
|
if (Retrace && CanRetrace) {
|
||||||
//time travel
|
//time travel
|
||||||
|
bool SavedOwnerSafe = OwnerSafe;
|
||||||
|
OwnerSafe = LastTraceOwnerSafe;
|
||||||
float remainingTime = LastTraceDelta;
|
float remainingTime = LastTraceDelta;
|
||||||
int remainingSteps = MaxTracesPerStep;
|
int remainingSteps = MaxTracesPerStep;
|
||||||
FVector PreviousVelocity = LastTracePrevVelocity;
|
FVector PreviousVelocity = LastTracePrevVelocity;
|
||||||
@ -87,6 +89,7 @@ void AEBBullet::Step(float DeltaTime) {
|
|||||||
remainingSteps -= 1;
|
remainingSteps -= 1;
|
||||||
if (remainingTime > 0.0f) { sendUpdate = true; };
|
if (remainingTime > 0.0f) { sendUpdate = true; };
|
||||||
} while (remainingTime > 0.0f && remainingSteps > 0);
|
} while (remainingTime > 0.0f && remainingSteps > 0);
|
||||||
|
OwnerSafe = SavedOwnerSafe;
|
||||||
}
|
}
|
||||||
CanRetrace = false;
|
CanRetrace = false;
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,8 @@ float AEBBullet::Trace(FVector start, FVector PreviousVelocity, float delta, TEn
|
|||||||
|
|
||||||
#ifdef WITH_EDITOR
|
#ifdef WITH_EDITOR
|
||||||
if (DebugEnabled) {
|
if (DebugEnabled) {
|
||||||
DrawDebugLine(GetWorld(), start, HitResult.Location, FColor::Blue, false, DebugTrailTime, 0, 3.0f);
|
FColor DebugColor = FColor::MakeRedToGreenColorFromScalar(Velocity.Size() / MuzzleVelocityMax);
|
||||||
|
DrawDebugLine(GetWorld(), start, HitResult.Location, DebugColor, false, DebugTrailTime, 0, DebugTrailWidth);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -178,6 +179,7 @@ float AEBBullet::Trace(FVector start, FVector PreviousVelocity, float delta, TEn
|
|||||||
LastTraceDelta = delta;
|
LastTraceDelta = delta;
|
||||||
LastTracePrevVelocity = PreviousVelocity;
|
LastTracePrevVelocity = PreviousVelocity;
|
||||||
LastTraceVelocity = Velocity;
|
LastTraceVelocity = Velocity;
|
||||||
|
LastTraceOwnerSafe = OwnerSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetActorLocation(start + TraceDistance);
|
SetActorLocation(start + TraceDistance);
|
||||||
@ -187,7 +189,8 @@ float AEBBullet::Trace(FVector start, FVector PreviousVelocity, float delta, TEn
|
|||||||
|
|
||||||
#ifdef WITH_EDITOR
|
#ifdef WITH_EDITOR
|
||||||
if (DebugEnabled) {
|
if (DebugEnabled) {
|
||||||
DrawDebugLine(GetWorld(), start, start + TraceDistance, FColor::Magenta, false, DebugTrailTime, 0, 3.0f);
|
FLinearColor Color = GetDebugColor(Velocity.Size() / ((MuzzleVelocityMin + MuzzleVelocityMax)*0.5f));
|
||||||
|
DrawDebugLine(GetWorld(), start, start + TraceDistance, Color.ToFColor(true), false, DebugTrailTime, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -208,6 +208,7 @@ private:
|
|||||||
float LastTraceDelta;
|
float LastTraceDelta;
|
||||||
FVector LastTraceVelocity;
|
FVector LastTraceVelocity;
|
||||||
FVector LastTracePrevVelocity;
|
FVector LastTracePrevVelocity;
|
||||||
|
bool LastTraceOwnerSafe = false;
|
||||||
|
|
||||||
bool IsRecycled;
|
bool IsRecycled;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user