Implemented Hover Bike Linear Landing Shock Absurber

This commit is contained in:
Rafal Swierczek 2024-02-25 17:30:02 +00:00
parent dca168ca3d
commit a2018e02ac
3 changed files with 12 additions and 13 deletions

Binary file not shown.

View File

@ -75,22 +75,17 @@ void ASpaceShip::BikeElevationPhysics(float DeltaTime)
CollisionQueryParams.AddIgnoredActor(this);
FVector LT_Start = GetActorLocation();
LT_Start.Z += 150;
FVector LT_End = LT_Start + FVector(0, 0, -450);
FVector LT_End = LT_Start + FVector(0, 0, -750);
if (GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_WorldStatic, CollisionQueryParams))
{
HighestElevationPoint = OutHit.Location.Z;
}
DrawDebugPoint(GetWorld(), OutHit.Location, 50, FColor::Red);
DrawDebugLine(GetWorld(), LT_Start, LT_End, FColor::Red, false, -1, 0, 5);
LT_Start = UKismetMathLibrary::TransformLocation(GetActorTransform(), FVector(MovementOffsetForLT[MovementVec.Y] ,MovementOffsetForLT[MovementVec.X], 150));
LT_End = LT_Start + FVector(0, 0, -600);
LT_End = LT_Start + FVector(0, 0, -750);
if (GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_WorldStatic, CollisionQueryParams) && OutHit.Distance != 0)
{
HighestElevationPoint = OutHit.Location.Z;
UE_LOG(LogTemp, Warning, TEXT("valid point"));
}
DrawDebugPoint(GetWorld(), OutHit.Location, 50, FColor::Green);
DrawDebugLine(GetWorld(), LT_Start, LT_End, FColor::Green, false, -1, 0, 5);
if (HighestElevationPoint <= -99999998)
{
float GravityAcc = 9.81 * DeltaTime;
@ -101,10 +96,13 @@ void ASpaceShip::BikeElevationPhysics(float DeltaTime)
SetActorLocation(NewLoc, true);
return;
}
if (CurrentFallSpeed > 0)
{
CurrentFallSpeed = 0;
}
float TargetElevation = HighestElevationPoint + HoverHeight;
float DistanceToTarget = TargetElevation - GetActorLocation().Z;
float IncrementToTarget = DistanceToTarget * DeltaTime * 2;
FVector CurrentActorLoc = GetActorLocation();
CurrentActorLoc.Z += IncrementToTarget;
SetActorLocation(CurrentActorLoc, true);
CurrentFallSpeed = 0;
}
// Called every frame

View File

@ -28,6 +28,7 @@ class ENDLESSVENDETTA_API ASpaceShip : public ACharacter
TMap<float, double> MovementOffsetForLT;
float CurrentFallSpeed = 0;
float TerminalFallSpeed = 100;
float HoverHeight = 50;
FVector2D MovementVec;
USpringArmComponent* BikeParentComp;