Added acceleration to the movement

This commit is contained in:
JKuijperM 2023-01-07 11:12:06 +01:00
parent 20063b408c
commit 4fa44a809a
3 changed files with 8 additions and 11 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:a382241647580d65fcb11eaed49b5c9e28ca99e8efd50ddb5f8f7c27bce6d1ae oid sha256:eae19cff0d1a7ec399f2bed7ddebeb12a0cd1464b7cc3aac8997e573ce9f340f
size 35058 size 35109

View File

@ -153,19 +153,14 @@ void AZombieCharacter::MoveForwardConstant(float DeltaTime)
{ {
if (bStraight) if (bStraight)
{ {
FVector vLocation = GetActorLocation(); FVector vLocation = GetActorLocation();
vLocation += GetActorForwardVector() * fBaseSpeed * DeltaTime; fBaseSpeed += fAcceleration * DeltaTime;
vLocation += GetActorForwardVector() * fBaseSpeed;
SetActorLocation(vLocation); SetActorLocation(vLocation);
} }
else else
{ {
RotateCharacter(); RotateCharacter();
FVector vLocation = GetActorLocation();
/*FVector forward = GetActorForwardVector();
UE_LOG(LogTemp, Warning, TEXT("x: %.2f, y: %.2f, z: %.2f"), forward.X, forward.Y, forward.Z);*/
vLocation += vCurrentDirection * 30.f * DeltaTime;
SetActorLocation(vLocation);
bStraight = true; bStraight = true;
} }

View File

@ -62,7 +62,9 @@ public:
// Base speed // Base speed
UPROPERTY(EditAnywhere, Category = "Movement") UPROPERTY(EditAnywhere, Category = "Movement")
float fBaseSpeed = 100.f; float fBaseSpeed = 5.f;
UPROPERTY(EditAnywhere, Category = "Movement")
float fAcceleration = .001f;
void RotateCharacter(); void RotateCharacter();
bool bStraight = true; bool bStraight = true;