From 9526c2a7542c2afd34067bbaa2553099636c883f Mon Sep 17 00:00:00 2001 From: JKuijperM Date: Fri, 6 Jan 2023 11:55:53 +0100 Subject: [PATCH] Created the turn left tile and modified the collision --- Content/Blueprints/BP_PathGenerator.uasset | 4 +-- .../Blueprints/Tiles/BP_TileTurnLeft.uasset | 3 ++ .../Blueprints/Tiles/BP_TileTurnRight.uasset | 4 +-- .../Road/roadAsphalt_corner.uasset | 4 +-- Source/EndlessZombie/PathGenerator.cpp | 1 + Source/EndlessZombie/TileCurve.cpp | 11 ++------ Source/EndlessZombie/ZombieCharacter.cpp | 28 +++---------------- Source/EndlessZombie/ZombieCharacter.h | 4 +-- 8 files changed, 18 insertions(+), 41 deletions(-) create mode 100644 Content/Blueprints/Tiles/BP_TileTurnLeft.uasset diff --git a/Content/Blueprints/BP_PathGenerator.uasset b/Content/Blueprints/BP_PathGenerator.uasset index 83e345e..287a362 100644 --- a/Content/Blueprints/BP_PathGenerator.uasset +++ b/Content/Blueprints/BP_PathGenerator.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:37e7daf1431d2c994ad4027c7f1a025693551f04212539b979a231e00c4f5925 -size 22666 +oid sha256:ef7d569bc00343bf21433a9cfd84c174063e963a6b5ea0e7c07f2ac11bfcfd8f +size 22827 diff --git a/Content/Blueprints/Tiles/BP_TileTurnLeft.uasset b/Content/Blueprints/Tiles/BP_TileTurnLeft.uasset new file mode 100644 index 0000000..3370591 --- /dev/null +++ b/Content/Blueprints/Tiles/BP_TileTurnLeft.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4908692256a8bd59e7a12cfecd3986e5e29047fbc1e08e067a7a2aa949f72efe +size 36617 diff --git a/Content/Blueprints/Tiles/BP_TileTurnRight.uasset b/Content/Blueprints/Tiles/BP_TileTurnRight.uasset index 21ed4ed..ebc8972 100644 --- a/Content/Blueprints/Tiles/BP_TileTurnRight.uasset +++ b/Content/Blueprints/Tiles/BP_TileTurnRight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:128870a6a999e250ae12fe9bf93bd5b80915245a672072c449950e09e49c5de4 -size 32357 +oid sha256:4702776094ca194fc90b39435008fab198657e64f32856c9877692905f37138d +size 36794 diff --git a/Content/StaticMeshes/Road/roadAsphalt_corner.uasset b/Content/StaticMeshes/Road/roadAsphalt_corner.uasset index b0b79a0..86a17ba 100644 --- a/Content/StaticMeshes/Road/roadAsphalt_corner.uasset +++ b/Content/StaticMeshes/Road/roadAsphalt_corner.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4e620fed07f31f7c8b4d0fb8dd2ed2573c0eeb3fafe04db388fee2392bf4cad -size 19728 +oid sha256:60905fe7b9218b65432b582878be699759c98b01a47d4cbc5588b1907328e32d +size 20422 diff --git a/Source/EndlessZombie/PathGenerator.cpp b/Source/EndlessZombie/PathGenerator.cpp index 0c19eb3..1f53b78 100644 --- a/Source/EndlessZombie/PathGenerator.cpp +++ b/Source/EndlessZombie/PathGenerator.cpp @@ -21,6 +21,7 @@ void APathGenerator::BeginPlay() AddSelectedTile(Tiles[0]); } AddSelectedTile(Tiles[1]); + AddSelectedTile(Tiles[2]); } diff --git a/Source/EndlessZombie/TileCurve.cpp b/Source/EndlessZombie/TileCurve.cpp index 2d8a835..dc96511 100644 --- a/Source/EndlessZombie/TileCurve.cpp +++ b/Source/EndlessZombie/TileCurve.cpp @@ -30,22 +30,17 @@ void ATileCurve::TurnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AAct { if (!bWasTriggered) { - // Yaw - float fYawValue; - if (bTurnRight && !bTurnLeft) { UE_LOG(LogTemp, Warning, TEXT("[ATileCurve::OnBeginOverlapChild] Rotating right")); - fYawValue = 90.f; - FRotator NewRotation = FRotator(0.f, fYawValue, 0.f); ZombieCharacter->bStraight = false; - ZombieCharacter->NewRotation = NewRotation; - //ZombieCharacter->RotateCharacter(NewRotation); + ZombieCharacter->iSideTurn = 1; } else if (!bTurnRight && bTurnLeft) { UE_LOG(LogTemp, Warning, TEXT("[ATileCurve::OnBeginOverlapChild] Rotating left")); - fYawValue = -90.f; + ZombieCharacter->bStraight = false; + ZombieCharacter->iSideTurn = -1; } else { diff --git a/Source/EndlessZombie/ZombieCharacter.cpp b/Source/EndlessZombie/ZombieCharacter.cpp index 6895c5a..5987094 100644 --- a/Source/EndlessZombie/ZombieCharacter.cpp +++ b/Source/EndlessZombie/ZombieCharacter.cpp @@ -99,9 +99,6 @@ void AZombieCharacter::Tick(float DeltaTime) { MoveForwardConstant(DeltaTime); } - - //NewRotation.Yaw += 5.f; - //RotateCharacter(a); } // Called to bind functionality to input @@ -187,27 +184,11 @@ void AZombieCharacter::PlayTurn() } } -void AZombieCharacter::UpdateDirection(int i) -{ - iCurrentDirection += i; - if (iCurrentDirection > mDirections.Num()) - { - iCurrentDirection = 0; - } - else if (iCurrentDirection < 0) - { - iCurrentDirection = mDirections.Num(); - } - - vCurrentDirection = mDirections[iCurrentDirection]; -} - void AZombieCharacter::RotateCharacter() { FRotator CurrentRotation = GetActorRotation(); + fControlTurn = 0.f; PlayTurn(); - UE_LOG(LogTemp, Warning, TEXT("Girao")); - //Controller->SetControlRotation(NewRotation + CurrentRotation); } void AZombieCharacter::ControlTurning() @@ -224,11 +205,10 @@ void AZombieCharacter::ControlTurning() if (fControlTurn <= 90.f) { FRotator CurrentRotation = Controller->GetControlRotation(); - CurrentRotation.Yaw += fVal; + CurrentRotation.Yaw += fVal * iSideTurn; Controller->SetControlRotation(CurrentRotation); UE_LOG(LogTemp, Warning, TEXT("[AZombieCharacter::ControlTurning] Yaw: %f"), CurrentRotation.Yaw); - UE_LOG(LogTemp, Warning, TEXT("[AZombieCharacter::ControlTurning] Control Turn: %f"), fControlTurn); - + UE_LOG(LogTemp, Warning, TEXT("[AZombieCharacter::ControlTurning] Control Turn: %f"), fControlTurn); } } @@ -238,5 +218,5 @@ void AZombieCharacter::SetState() bReadyState = true; bTurning = false; bStraight = true; - UE_LOG(LogTemp, Warning, TEXT("[AZombieCharacter::SetState] Set state")); + fPrevCurvValue = 0.f; } \ No newline at end of file diff --git a/Source/EndlessZombie/ZombieCharacter.h b/Source/EndlessZombie/ZombieCharacter.h index d97016d..7c5f3db 100644 --- a/Source/EndlessZombie/ZombieCharacter.h +++ b/Source/EndlessZombie/ZombieCharacter.h @@ -66,7 +66,7 @@ public: void RotateCharacter(); bool bStraight = true; - FRotator NewRotation = FRotator(0.f, 0.f, 0.f); + int iSideTurn = 1; // Properties for the timeline to turn right UFUNCTION() @@ -87,8 +87,6 @@ public: int iCurrentDirection = 0; FVector vCurrentDirection; - void UpdateDirection(int i); - private: void MoveForwardConstant(float DeltaTime);