Implemented Hover Bike Linear Landing Shock Absurber
This commit is contained in:
parent
dca168ca3d
commit
a2018e02ac
BIN
EndlessVendetta/Content/Levels/OpenWorldRework.umap
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Levels/OpenWorldRework.umap
(Stored with Git LFS)
Binary file not shown.
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user