Fix air spline locomotion and flat spline
This commit is contained in:
parent
75c325c4cc
commit
29fd695a03
BIN
Pawn_Unreal/Content/Characters/BP_Judy.uasset
(Stored with Git LFS)
BIN
Pawn_Unreal/Content/Characters/BP_Judy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Pawn_Unreal/Content/Characters/Base/ABP_Character.uasset
(Stored with Git LFS)
BIN
Pawn_Unreal/Content/Characters/Base/ABP_Character.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Pawn_Unreal/Content/Systems/Modes/Combat/BP_CombatPlatformerPath.uasset
(Stored with Git LFS)
BIN
Pawn_Unreal/Content/Systems/Modes/Combat/BP_CombatPlatformerPath.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/1/XM/TP8DFTZ6ODOTSDOLG6WEXZ.uasset
(Stored with Git LFS)
Normal file
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/1/XM/TP8DFTZ6ODOTSDOLG6WEXZ.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/9/RQ/JYNZEWOG6SXNE3HGUCSZIE.uasset
(Stored with Git LFS)
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/9/RQ/JYNZEWOG6SXNE3HGUCSZIE.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/A/1J/FGN60CK2BMBEJRXHZ72TKV.uasset
(Stored with Git LFS)
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/A/1J/FGN60CK2BMBEJRXHZ72TKV.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/B/0Z/X5N2DTGOJMHQWHOBBKFNDX.uasset
(Stored with Git LFS)
BIN
Pawn_Unreal/Content/__ExternalActors__/Maps/Dev/MAP_ControllerGym/B/0Z/X5N2DTGOJMHQWHOBBKFNDX.uasset
(Stored with Git LFS)
Binary file not shown.
@ -48,8 +48,7 @@ void UPwnCharacterMovementComponent::OnMovementModeChanged(EMovementMode Previou
|
||||
Super::OnMovementModeChanged(PreviousMovementMode, PreviousCustomMode);
|
||||
|
||||
// React to changes in the movement mode.
|
||||
if (MovementMode == MOVE_Custom && CustomMovementMode == SplineWalking)
|
||||
{
|
||||
if (MovementMode == MOVE_Custom && CustomMovementMode == SplineWalking) {
|
||||
// make sure we update our new floor/base on initial entry of the walking physics
|
||||
FindFloor(UpdatedComponent->GetComponentLocation(), CurrentFloor, false);
|
||||
AdjustFloorHeight();
|
||||
@ -112,7 +111,7 @@ bool UPwnCharacterMovementComponent::IsCustomMovementMode(const ECustomMovementM
|
||||
void UPwnCharacterMovementComponent::RecomputeTangentAndAcceleration() {
|
||||
Tangent2D = CombatPath->Spline->GetTangentAtDistanceAlongSpline(DistanceAlongSpline, ESplineCoordinateSpace::World).GetSafeNormal2D();
|
||||
// Recalculate acceleration so the input is relative to the spline
|
||||
Acceleration = Tangent2D * Acceleration.Size2D() * FMath::Sign(Acceleration.X);
|
||||
Acceleration = Tangent2D * Acceleration.Size2D() * FMath::Sign(Acceleration.X) * DotDirection;
|
||||
}
|
||||
|
||||
void UPwnCharacterMovementComponent::UpdatePawnVelocity(const float TimeTick) {
|
||||
@ -140,10 +139,23 @@ void UPwnCharacterMovementComponent::UpdatePawnVelocity(const float TimeTick) {
|
||||
DistanceAlongSpline = NewDistanceAlongSpline;
|
||||
}
|
||||
|
||||
void UPwnCharacterMovementComponent::UpdateDistanceAlongSpline() {
|
||||
void UPwnCharacterMovementComponent::UpdateDistanceAlongSplineAndLocation() {
|
||||
// Maintain coherent distance along spline with location
|
||||
const float InputKey = CombatPath->Spline->FindInputKeyClosestToWorldLocation(UpdatedComponent->GetComponentLocation());
|
||||
FHitResult Hit;
|
||||
FCollisionQueryParams QueryParams;
|
||||
QueryParams.AddIgnoredActor(GetOwner());
|
||||
if (GetWorld()->LineTraceSingleByChannel(Hit, UpdatedComponent->GetComponentLocation(),
|
||||
UpdatedComponent->GetComponentLocation() + FVector(0.0f, 0.0f, -10000.0f),
|
||||
ECC_Visibility, QueryParams)) {
|
||||
|
||||
FVector ImpactPoint = Hit.ImpactPoint;
|
||||
const float InputKey = CombatPath->Spline->FindInputKeyClosestToWorldLocation(ImpactPoint);
|
||||
DistanceAlongSpline = CombatPath->Spline->GetDistanceAlongSplineAtSplineInputKey(InputKey);
|
||||
}
|
||||
|
||||
FVector TargetLocation = CombatPath->Spline->GetLocationAtDistanceAlongSpline(DistanceAlongSpline, ESplineCoordinateSpace::World);
|
||||
TargetLocation.Z = UpdatedComponent->GetComponentLocation().Z;
|
||||
UpdatedComponent->SetWorldLocation(TargetLocation);
|
||||
}
|
||||
|
||||
void UPwnCharacterMovementComponent::PhysSplineWalking(const float DeltaTime, int32 Iterations) {
|
||||
@ -183,15 +195,15 @@ void UPwnCharacterMovementComponent::PhysSplineWalking(const float DeltaTime, in
|
||||
const FVector OldLocation = UpdatedComponent->GetComponentLocation();
|
||||
const FFindFloorResult OldFloor = CurrentFloor;
|
||||
|
||||
RecomputeTangentAndAcceleration(); /* -- PAWN MODIFICATIONS -- */
|
||||
Acceleration.Z = 0.f;
|
||||
|
||||
RestorePreAdditiveRootMotionVelocity();
|
||||
|
||||
// Ensure velocity is horizontal.
|
||||
MaintainHorizontalGroundVelocity();
|
||||
const FVector OldVelocity = Velocity;
|
||||
|
||||
RecomputeTangentAndAcceleration(); /* -- PAWN MODIFICATIONS -- */
|
||||
Acceleration.Z = 0.f;
|
||||
|
||||
// Apply acceleration
|
||||
if (!HasAnimRootMotion() && !CurrentRootMotion.HasOverrideVelocity()) {
|
||||
CalcVelocity(TimeTick, GroundFriction, false, GetMaxBrakingDeceleration());
|
||||
@ -343,7 +355,7 @@ void UPwnCharacterMovementComponent::PhysSplineWalking(const float DeltaTime, in
|
||||
MaintainHorizontalGroundVelocity();
|
||||
}
|
||||
|
||||
UpdateDistanceAlongSpline(); /* -- PAWN MODIFICATIONS -- */
|
||||
UpdateDistanceAlongSplineAndLocation(); /* -- PAWN MODIFICATIONS -- */
|
||||
}
|
||||
|
||||
UE_DISABLE_OPTIMIZATION
|
||||
@ -353,6 +365,8 @@ void UPwnCharacterMovementComponent::PhysSplineFalling(const float DeltaTime, in
|
||||
return;
|
||||
}
|
||||
|
||||
RecomputeTangentAndAcceleration(); /* -- PAWN MODIFICATIONS -- */
|
||||
|
||||
FVector FallAcceleration = GetFallingLateralAcceleration(DeltaTime);
|
||||
FallAcceleration.Z = 0.f;
|
||||
const bool bHasLimitedAirControl = ShouldLimitAirControl(DeltaTime, FallAcceleration);
|
||||
@ -367,8 +381,6 @@ void UPwnCharacterMovementComponent::PhysSplineFalling(const float DeltaTime, in
|
||||
const FQuat PawnRotation = UpdatedComponent->GetComponentQuat();
|
||||
bJustTeleported = false;
|
||||
|
||||
RecomputeTangentAndAcceleration(); /* -- PAWN MODIFICATIONS -- */
|
||||
|
||||
const FVector OldVelocityWithRootMotion = Velocity;
|
||||
|
||||
RestorePreAdditiveRootMotionVelocity();
|
||||
@ -657,7 +669,7 @@ void UPwnCharacterMovementComponent::PhysSplineFalling(const float DeltaTime, in
|
||||
}
|
||||
}
|
||||
|
||||
UpdateDistanceAlongSpline(); /* -- PAWN MODIFICATIONS -- */
|
||||
UpdateDistanceAlongSplineAndLocation(); /* -- PAWN MODIFICATIONS -- */
|
||||
}
|
||||
|
||||
UE_ENABLE_OPTIMIZATION
|
||||
|
||||
@ -19,6 +19,26 @@ void APwnCombatPlatformerPath::BeginPlay() {
|
||||
UPwnGameplayModeSubsystem* Subsystem = GetWorld()->GetSubsystem<UPwnGameplayModeSubsystem>();
|
||||
check(Subsystem);
|
||||
Subsystem->RegisterCombatPath(this);
|
||||
|
||||
const FVector FirstPointLocation = Spline->GetLocationAtSplinePoint(0, ESplineCoordinateSpace::World);
|
||||
float FirstPointZ = FirstPointLocation.Z;
|
||||
|
||||
const int32 PointsCount = Spline->GetNumberOfSplinePoints();
|
||||
for (int i = 0; i < PointsCount; ++i) {
|
||||
FVector NewLocation = Spline->GetLocationAtSplinePoint(i, ESplineCoordinateSpace::World);
|
||||
NewLocation.Z = FirstPointZ;
|
||||
Spline->SetLocationAtSplinePoint(i, NewLocation, ESplineCoordinateSpace::World, false);
|
||||
|
||||
FVector ArriveTangent = Spline->GetArriveTangentAtSplinePoint(i, ESplineCoordinateSpace::World);
|
||||
FVector LeaveTangent = Spline->GetLeaveTangentAtSplinePoint(i, ESplineCoordinateSpace::World);
|
||||
|
||||
ArriveTangent.Z = 0;
|
||||
LeaveTangent.Z = 0;
|
||||
Spline->SetTangentsAtSplinePoint(i, ArriveTangent, LeaveTangent, ESplineCoordinateSpace::World, false);
|
||||
}
|
||||
|
||||
Spline->UpdateSpline();
|
||||
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ private:
|
||||
|
||||
void UpdatePawnVelocity(const float TimeTick);
|
||||
|
||||
void UpdateDistanceAlongSpline();
|
||||
void UpdateDistanceAlongSplineAndLocation();
|
||||
|
||||
void PhysSplineWalking(const float DeltaTime, int32 Iterations);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user