Implemented Dynamic Ground Checks Based on Movement Input
This commit is contained in:
parent
82a4951990
commit
a517eeb5b8
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
Binary file not shown.
@ -5,7 +5,6 @@
|
||||
|
||||
#include "Components/ArrowComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
|
||||
// Sets default values
|
||||
@ -13,6 +12,9 @@ ASpaceShip::ASpaceShip()
|
||||
{
|
||||
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
MovementOffsetForLT.Add(-1.f, -400);
|
||||
MovementOffsetForLT.Add(0.f, 0);
|
||||
MovementOffsetForLT.Add(1.f, 400);
|
||||
}
|
||||
|
||||
void ASpaceShip::SightCheck()
|
||||
@ -65,6 +67,24 @@ void ASpaceShip::BikeSwayBasedOnAcc(float DeltaTime)
|
||||
BikeParentComp->SetRelativeRotation(BikeRelativeRot);
|
||||
}
|
||||
|
||||
void ASpaceShip::BikeElevationPhysics(float DeltaTime)
|
||||
{
|
||||
FHitResult OutHit;
|
||||
FCollisionQueryParams CollisionQueryParams;
|
||||
CollisionQueryParams.AddIgnoredActor(this);
|
||||
FVector LT_Start = GetActorLocation();
|
||||
LT_Start.Z += 150;
|
||||
FVector LT_End = LT_Start + FVector(0, 0, -450);
|
||||
GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_WorldStatic, CollisionQueryParams);
|
||||
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);
|
||||
GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_WorldStatic, CollisionQueryParams);
|
||||
DrawDebugPoint(GetWorld(), OutHit.Location, 50, FColor::Green);
|
||||
DrawDebugLine(GetWorld(), LT_Start, LT_End, FColor::Green, false, -1, 0, 5);
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ASpaceShip::Tick(float DeltaTime)
|
||||
{
|
||||
@ -73,6 +93,7 @@ void ASpaceShip::Tick(float DeltaTime)
|
||||
PlayersCharacter->SetActorLocation(SeatComponent->GetComponentLocation());
|
||||
PlayersController->SetControlRotation(GetActorRotation());
|
||||
BikeSwayBasedOnAcc(DeltaTime);
|
||||
BikeElevationPhysics(DeltaTime);
|
||||
|
||||
SightCheck();
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ class ENDLESSVENDETTA_API ASpaceShip : public ACharacter
|
||||
|
||||
void BikeSwayBasedOnAcc(float DeltaTime);
|
||||
|
||||
void BikeElevationPhysics(float DeltaTime);
|
||||
TMap<float, double> MovementOffsetForLT;
|
||||
|
||||
FVector2D MovementVec;
|
||||
USpringArmComponent* BikeParentComp;
|
||||
FTimerHandle BikeLeanResetTimer;
|
||||
|
Loading…
Reference in New Issue
Block a user