Add spiral stair in Controller Gym

This commit is contained in:
Maxime Maurin 2023-11-25 12:24:02 +01:00
parent 49352f9c22
commit a55b8556ea
28 changed files with 30 additions and 67 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,7 +5,7 @@
#include "Components/SplineComponent.h"
#include "GameplayModes/PwnGameplayModeSubsystem.h"
#include "GameplayModes/Combat/PwnCombatPlatformerPath.h"
#include "Utils/EngineUtils.h"
#include "Kismet/KismetSystemLibrary.h"
constexpr float LineTraceDistance = 10000.0f;
@ -101,7 +101,8 @@ bool UPwnCharacterMovementComponent::IsCustomMovementMode(const ECustomMovementM
bool UPwnCharacterMovementComponent::LineTraceToGround(FHitResult& OutHit, const FVector& StartLocation) const {
const FVector EndLocation = StartLocation + FVector(0.0f, 0.0f, -LineTraceDistance);
return GetWorld()->LineTraceSingleByChannel(OutHit, StartLocation, EndLocation, ECC_Visibility, IGNORE_OWNER_PARAMS);
return UKismetSystemLibrary::LineTraceSingle(this, StartLocation, EndLocation, UEngineTypes::ConvertToTraceType(ECC_Visibility), false, TArray<AActor*>(),
EDrawDebugTrace::None, OutHit, true, FLinearColor::Red, FLinearColor::Green, 0.5f);
}
void UPwnCharacterMovementComponent::UpdateCurrentCombatPath(const bool UpdateLocation) {
@ -130,7 +131,9 @@ void UPwnCharacterMovementComponent::UpdateCurrentCombatPath(const bool UpdateLo
}
void UPwnCharacterMovementComponent::UpdateTangentAndAcceleration() {
Tangent2D = CombatPath->FlattenedSpline->GetTangentAtDistanceAlongSpline(DistanceAlongSpline, ESplineCoordinateSpace::World).GetSafeNormal2D();
// Clamp distance because tangents are not defined at the ends of the spline
const float ClampedDistanceAlongSpline = FMath::Clamp(DistanceAlongSpline, 0.0001f, CombatPath->FlattenedSpline->GetSplineLength() - 0.0001f);
Tangent2D = CombatPath->FlattenedSpline->GetTangentAtDistanceAlongSpline(ClampedDistanceAlongSpline, ESplineCoordinateSpace::World).GetSafeNormal2D();
// Recalculate acceleration so the input is relative to the spline
Acceleration = Tangent2D * Acceleration.Size2D() * FMath::Sign(Acceleration.X) * DotDirection;
}

View File

@ -51,7 +51,6 @@ void UPwnGameplayModeSubsystem::UnregisterCombatPath(APwnCombatPlatformerPath* C
bool UPwnGameplayModeSubsystem::FindClosestCombatPathLocation(const FVector& Location, APwnCombatPlatformerPath*& OutCombatPath) const {
float ShortestDistance = FLT_MAX;
APwnCombatPlatformerPath* ClosestCombatPath = nullptr;
bool Found = false;
for (APwnCombatPlatformerPath* CombatPath : CombatPaths) {
const USplineComponent* CurrentSpline = CombatPath->Spline;
@ -62,12 +61,12 @@ bool UPwnGameplayModeSubsystem::FindClosestCombatPathLocation(const FVector& Loc
if (CurrentDistance < ShortestDistance) {
ShortestDistance = CurrentDistance;
ClosestCombatPath = CombatPath;
Found = true;
}
}
if (Found) {
if (ClosestCombatPath != nullptr) {
OutCombatPath = ClosestCombatPath;
return true;
}
return Found;
return false;
}