From 6e0c1810145dd5434e5357ce61504dd21c7f9e4a Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 15 Jan 2022 19:19:22 -0500 Subject: [PATCH 1/4] First camera system; follows midpoint of both character's Y and Z pos First camera system; follows midpoint of both character's Y and Z pos --- .gitignore | 1 + .../Content/Core/BP_DefaultCamera.uasset | 3 + KOFForever/Content/Maps/TestMap.umap | 4 +- KOFForever/KOFForever.uproject | 3 +- .../Private/Camera/KOFDefaultCamera.cpp | 36 ++++++++++++ .../Private/Character/KOFBaseCharacter.cpp | 17 ------ .../Public/Camera/KOFDefaultCamera.h | 56 +++++++++++++++++++ .../Public/Character/KOFBaseCharacter.h | 13 ----- 8 files changed, 100 insertions(+), 33 deletions(-) create mode 100644 KOFForever/Content/Core/BP_DefaultCamera.uasset create mode 100644 KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp create mode 100644 KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h diff --git a/.gitignore b/.gitignore index 839866f..9111197 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ Build/*/** # Cache files for the editor to use **/DerivedDataCache/* +Scratch diff --git a/KOFForever/Content/Core/BP_DefaultCamera.uasset b/KOFForever/Content/Core/BP_DefaultCamera.uasset new file mode 100644 index 0000000..c408c80 --- /dev/null +++ b/KOFForever/Content/Core/BP_DefaultCamera.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6e1ed4c6c619bc2c8705abd07d29328d8d0400e48497b1e96256d9cf2842e94 +size 20151 diff --git a/KOFForever/Content/Maps/TestMap.umap b/KOFForever/Content/Maps/TestMap.umap index c2069a2..4c4cd3f 100644 --- a/KOFForever/Content/Maps/TestMap.umap +++ b/KOFForever/Content/Maps/TestMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65d157090f0f3aaa5437271f4b057f8cdc3903780bd72c0a461a303c6c7cb337 -size 8538726 +oid sha256:4b072fd78e49c25d512dc5058eaebf9320b15d8e49f6ae77ef409ce1ef92f219 +size 8537801 diff --git a/KOFForever/KOFForever.uproject b/KOFForever/KOFForever.uproject index 3e9a18f..f41e767 100644 --- a/KOFForever/KOFForever.uproject +++ b/KOFForever/KOFForever.uproject @@ -9,7 +9,8 @@ "Type": "Runtime", "LoadingPhase": "Default", "AdditionalDependencies": [ - "Paper2D" + "Paper2D", + "Engine" ] } ] diff --git a/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp b/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp new file mode 100644 index 0000000..f2af1db --- /dev/null +++ b/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp @@ -0,0 +1,36 @@ + + + +#include "Camera/KOFDefaultCamera.h" + +#include "DrawDebugHelpers.h" +#include "Camera/CameraComponent.h" + +AKOFDefaultCamera::AKOFDefaultCamera() +{ + PrimaryActorTick.bCanEverTick = true; + + MinFOV = 80.0f; + MaxFOV = 85.0f; + GetCameraComponent()->SetFieldOfView(MinFOV); + + HeightOffset = 60.0f; + ZAveragingFactor = 2.0f; +} + +void AKOFDefaultCamera::Tick(float DeltaSeconds) +{ + Super::Tick(DeltaSeconds); + + check(P1); + check(P2); + + FVector P1Loc = P1->GetActorLocation(); + FVector P2Loc = P2->GetActorLocation(); + FVector CameraLoc = GetActorLocation(); + + FVector MidPoint = FVector(CameraLoc.X, (P1Loc.Y + P2Loc.Y) / 2.0f, ((P1Loc.Z + P2Loc.Z) / ZAveragingFactor) + HeightOffset); + SetActorLocation(MidPoint); + + // set FOV +} diff --git a/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp b/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp index 39eff95..b3d384a 100644 --- a/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp +++ b/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp @@ -24,24 +24,7 @@ AKOFBaseCharacter::AKOFBaseCharacter() // Set the size of our collision capsule. GetCapsuleComponent()->SetCapsuleHalfHeight(96.0f); GetCapsuleComponent()->SetCapsuleRadius(40.0f); - - // Create a camera boom attached to the root (capsule) - CameraBoom = CreateDefaultSubobject(TEXT("CameraBoom")); - CameraBoom->SetupAttachment(RootComponent); - CameraBoom->TargetArmLength = 500.0f; - CameraBoom->SocketOffset = FVector(0.0f, 0.0f, 0.0f); - CameraBoom->bDoCollisionTest = false; - CameraBoom->SetRelativeRotation(FRotator(0.0f, 180.f, 0.0f)); - - // Create an orthographic camera (no perspective) and attach it to the boom - SideViewCameraComponent = CreateDefaultSubobject(TEXT("SideViewCamera")); - SideViewCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); - - // Prevent all automatic rotation behavior on the camera, character, and camera component - CameraBoom->SetUsingAbsoluteRotation(true); - SideViewCameraComponent->bUsePawnControlRotation = false; - SideViewCameraComponent->bAutoActivate = true; GetCharacterMovement()->bOrientRotationToMovement = false; // Configure character movement diff --git a/KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h b/KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h new file mode 100644 index 0000000..1a48a6c --- /dev/null +++ b/KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h @@ -0,0 +1,56 @@ + + +#pragma once + +#include "CoreMinimal.h" +#include "Camera/CameraActor.h" +#include "KOFDefaultCamera.generated.h" + +/** + * + */ +UCLASS() +class KOFFOREVER_API AKOFDefaultCamera : public ACameraActor +{ + GENERATED_BODY() + +public: + AKOFDefaultCamera(); + + virtual void Tick(float DeltaSeconds) override; +protected: + /** + * Min FOV camera will zoom in to as character's walk farther apart from each other. + * + * + */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = CameraSettings, meta = (UIMin = "5.0", UIMax = "170", ClampMin = "0.001", ClampMax = "360.0", Units = deg)) + float MinFOV; + + /** Max FOV camera will zoom out to as character's walk farther apart from each other */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = CameraSettings, meta = (UIMin = "5.0", UIMax = "170", ClampMin = "0.001", ClampMax = "360.0", Units = deg)) + float MaxFOV; + + /** Offset added to the camera's Z value after performing the character mid point calculation */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = CameraSettings) + float HeightOffset; + + /** + * Value used when averaging both character's Z positions to find the camera's final Z position. + * + * A value of 2.0 will set the camera's Z position to the midpoint between both character's Z positions. + * A value less than 2.0 will keep the camera closer to the ground even as another player jumps. + */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = CameraSettings) + float ZAveragingFactor; + + + // References to player main character's + // eventually we want to spawn all the player's characters from game mode? and then we can get the references to + // P1 and P2 from there. For now we'll just set the references manually in the level + UPROPERTY(EditAnywhere) + AActor* P1; + + UPROPERTY(EditAnywhere) + AActor* P2; +}; diff --git a/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h b/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h index 626b4ac..e9f7099 100644 --- a/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h +++ b/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h @@ -21,14 +21,6 @@ class KOFFOREVER_API AKOFBaseCharacter : public APaperCharacter { GENERATED_BODY() - /** Side view camera */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera, meta=(AllowPrivateAccess="true")) - class UCameraComponent* SideViewCameraComponent; - - /** Camera boom positioning the camera beside the character */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) - class USpringArmComponent* CameraBoom; - UTextRenderComponent* TextComponent; virtual void Tick(float DeltaSeconds) override; @@ -74,10 +66,5 @@ protected: public: AKOFBaseCharacter(); - /** Returns SideViewCameraComponent subobject **/ - FORCEINLINE class UCameraComponent* GetSideViewCameraComponent() const { return SideViewCameraComponent; } - /** Returns CameraBoom subobject **/ - FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } - FORCEINLINE class UPaperFlipbookComponent* GetShadow() const { return Shadow; } }; From 4d10d9cb32a936990642ff5798ab9444cd7c9b69 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 15 Jan 2022 23:41:56 -0500 Subject: [PATCH 2/4] Setup game mode so characters are spawned automatically rather than placing them in the world Setup game mode so characters are spawned automatically rather than placing them in the world --- KOFForever/Config/DefaultEngine.ini | 2 +- .../Core/BP_MainPlayerController.uasset | 4 +- .../Content/Debug/BP_DebugGameMode.uasset | 3 + KOFForever/Content/Maps/DebugStage.umap | 3 + KOFForever/Content/Maps/TrainingStage.umap | 3 + KOFForever/KOFForever.uproject | 3 +- .../Private/Camera/KOFDefaultCamera.cpp | 78 ++++++++++++++++--- .../Private/Character/KOFBaseCharacter.cpp | 6 +- .../Private/GameModes/KOFDefaultGameMode.cpp | 64 +++++++++++++++ .../KOFForever/Private/GameModes/KOFTeam.cpp | 23 ++++++ .../Public/Camera/KOFDefaultCamera.h | 13 ++-- .../Public/GameModes/KOFDefaultGameMode.h | 62 +++++++++++++++ .../KOFForever/Public/GameModes/KOFTeam.h | 38 +++++++++ 13 files changed, 278 insertions(+), 24 deletions(-) create mode 100644 KOFForever/Content/Debug/BP_DebugGameMode.uasset create mode 100644 KOFForever/Content/Maps/DebugStage.umap create mode 100644 KOFForever/Content/Maps/TrainingStage.umap create mode 100644 KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp create mode 100644 KOFForever/Source/KOFForever/Private/GameModes/KOFTeam.cpp create mode 100644 KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h create mode 100644 KOFForever/Source/KOFForever/Public/GameModes/KOFTeam.h diff --git a/KOFForever/Config/DefaultEngine.ini b/KOFForever/Config/DefaultEngine.ini index d505c84..32eb7ba 100644 --- a/KOFForever/Config/DefaultEngine.ini +++ b/KOFForever/Config/DefaultEngine.ini @@ -1,7 +1,7 @@ [/Script/EngineSettings.GameMapsSettings] -EditorStartupMap=/Game/Maps/TestMap.TestMap +EditorStartupMap=/Game/Maps/DebugStage.DebugStage LocalMapOptions= TransitionMap= bUseSplitscreen=True diff --git a/KOFForever/Content/Core/BP_MainPlayerController.uasset b/KOFForever/Content/Core/BP_MainPlayerController.uasset index 4333401..6081e77 100644 --- a/KOFForever/Content/Core/BP_MainPlayerController.uasset +++ b/KOFForever/Content/Core/BP_MainPlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1164cabcfba95e36b36315217ddb67fcabd1309beae3fa94954a0119705bd8c -size 32353 +oid sha256:8b9c8e5425cb6b9cb031b489c49e5f4eb921c202d4ffdc0f1ac7d887531b4fde +size 32282 diff --git a/KOFForever/Content/Debug/BP_DebugGameMode.uasset b/KOFForever/Content/Debug/BP_DebugGameMode.uasset new file mode 100644 index 0000000..20b1415 --- /dev/null +++ b/KOFForever/Content/Debug/BP_DebugGameMode.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7770532361694fba926359a02f4874cec86d186ebf88b22a2e308c29d4bf8f17 +size 18779 diff --git a/KOFForever/Content/Maps/DebugStage.umap b/KOFForever/Content/Maps/DebugStage.umap new file mode 100644 index 0000000..9fa925c --- /dev/null +++ b/KOFForever/Content/Maps/DebugStage.umap @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0734c34f22596584ab16ae499c6df6869ce893efc067598c4e80b8a451b6677d +size 8531398 diff --git a/KOFForever/Content/Maps/TrainingStage.umap b/KOFForever/Content/Maps/TrainingStage.umap new file mode 100644 index 0000000..c61a29a --- /dev/null +++ b/KOFForever/Content/Maps/TrainingStage.umap @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33c22cc90246a4c63062ba2f5906b7ceff8f0bbbfa78189551a2811f3e5e2055 +size 8536856 diff --git a/KOFForever/KOFForever.uproject b/KOFForever/KOFForever.uproject index f41e767..0451eda 100644 --- a/KOFForever/KOFForever.uproject +++ b/KOFForever/KOFForever.uproject @@ -10,7 +10,8 @@ "LoadingPhase": "Default", "AdditionalDependencies": [ "Paper2D", - "Engine" + "Engine", + "CoreUObject" ] } ] diff --git a/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp b/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp index f2af1db..16ae7c2 100644 --- a/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp +++ b/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp @@ -5,6 +5,8 @@ #include "DrawDebugHelpers.h" #include "Camera/CameraComponent.h" +#include "Character/KOFBaseCharacter.h" +#include "GameModes/KOFDefaultGameMode.h" AKOFDefaultCamera::AKOFDefaultCamera() { @@ -16,21 +18,79 @@ AKOFDefaultCamera::AKOFDefaultCamera() HeightOffset = 60.0f; ZAveragingFactor = 2.0f; + + MovementYDistanceThreshold = 500.0f; } void AKOFDefaultCamera::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); - check(P1); - check(P2); + // NOTE(kevin): This will only return the game mode if we are the server. Since this game is local only we should always + // be both server and client + AKOFDefaultGameMode* GameMode = Cast(GetWorld()->GetAuthGameMode()); - FVector P1Loc = P1->GetActorLocation(); - FVector P2Loc = P2->GetActorLocation(); - FVector CameraLoc = GetActorLocation(); + if(GameMode) + { + AKOFBaseCharacter* P1 = GameMode->GetP1CurrentCharacter(); + AKOFBaseCharacter* P2 = GameMode->GetP2CurrentCharacter(); + + check(P1); + check(P2); - FVector MidPoint = FVector(CameraLoc.X, (P1Loc.Y + P2Loc.Y) / 2.0f, ((P1Loc.Z + P2Loc.Z) / ZAveragingFactor) + HeightOffset); - SetActorLocation(MidPoint); - - // set FOV + FVector P1Loc = P1->GetActorLocation(); + FVector P2Loc = P2->GetActorLocation(); + FVector CameraLoc = GetActorLocation(); + + FVector MidPoint = FVector(CameraLoc.X, (P1Loc.Y + P2Loc.Y) / 2.0f, ((P1Loc.Z + P2Loc.Z) / ZAveragingFactor) + HeightOffset); + SetActorLocation(MidPoint); + + // set FOV + } } + +void AKOFDefaultCamera::UpdateCamera() +{ + // NOTE(kevin): This will only return the game mode if we are the server. Since this game is local only we should always + // be both server and client + AKOFDefaultGameMode* GameMode = Cast(GetWorld()->GetAuthGameMode()); + + if(GameMode) + { + AKOFBaseCharacter* P1 = GameMode->GetP1CurrentCharacter(); + AKOFBaseCharacter* P2 = GameMode->GetP2CurrentCharacter(); + + FVector P1Loc = P1->GetActorLocation(); + FVector P2Loc = P2->GetActorLocation(); + FVector CameraLoc = GetActorLocation(); + + float HalfMoveYThreshold = MovementYDistanceThreshold / 2.0f; + + float YDistance = FMath::Abs(P1Loc.Y - P2Loc.Y); + + /** + * If one of the characters starts to move far enough to either side of the camera (determined by Movement Y distance threshold), + * then start pushing the camera in that same direction + */ + /* + if((P1Loc.Y < CameraLoc.Y - HalfMoveYThreshold || P2Loc.Y < CameraLoc.Y - HalfMoveYThreshold) || + (P1Loc.Y > CameraLoc.Y + HalfMoveYThreshold || P2Loc.Y > CameraLoc.Y + HalfMoveYThreshold)) + { + //FVector MidPoint = FVector(CameraLoc.X, (P1Loc.Y + P2Loc.Y) / 2.0f, ((P1Loc.Z + P2Loc.Z) / ZAveragingFactor) + HeightOffset); + FVector MidPoint = FVector(CameraLoc.X, (P1Loc.Y + P2Loc.Y) / 2.0f, CameraLoc.Z); + SetActorLocation(MidPoint); + } + */ + + + // leftest = MaxF(float32(Min(s.stage.p[0].startx, s.stage.p[1].startx))*s.stage.localscl,-(float32(s.gameWidth)/2)/s.cam.BaseScale()+s.screenleft) - ox + // rightest = MinF(float32(Max(s.stage.p[0].startx, s.stage.p[1].startx))*s.stage.localscl, (float32(s.gameWidth)/2)/s.cam.BaseScale()-s.screenright) - ox + + float MoveRightVal = P1Loc.Y > CameraLoc.Y + HalfMoveYThreshold ? P1Loc.Y - (CameraLoc.Y + HalfMoveYThreshold) : 0.0f; + float MoveLeftVal = P1Loc.Y < CameraLoc.Y - HalfMoveYThreshold ? P1Loc.Y - (CameraLoc.Y - HalfMoveYThreshold) : 0.0f; + + FVector NewLocation = FVector(CameraLoc.X, (CameraLoc.Y + MoveRightVal - MoveLeftVal), CameraLoc.Z); + } +} + + diff --git a/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp b/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp index b3d384a..000fc00 100644 --- a/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp +++ b/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp @@ -85,11 +85,11 @@ void AKOFBaseCharacter::UpdateAnimation() UPaperFlipbook* DesiredAnimation = IdleAnimation; if(PlayerSpeedSqr > 0.0f) { - if (TravelDirection < 0.0f) + if (TravelDirection > 0.0f) { DesiredAnimation = WalkFwdAnimation; } - else if (TravelDirection > 0.0f) + else if (TravelDirection < 0.0f) { DesiredAnimation = WalkBackAnimation; } @@ -152,7 +152,7 @@ void AKOFBaseCharacter::MoveRight(float Value) /*UpdateChar();*/ // Apply the input to the character motion - AddMovementInput(FVector(0.0f, -1.0f, 0.0f), Value); + AddMovementInput(FVector(0.0f, 1.0f, 0.0f), Value); } void AKOFBaseCharacter::UpdateCharacter() diff --git a/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp b/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp new file mode 100644 index 0000000..cb54cbd --- /dev/null +++ b/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp @@ -0,0 +1,64 @@ + + + +#include "GameModes/KOFDefaultGameMode.h" + +#include "Kismet/GameplayStatics.h" + +AKOFDefaultGameMode::AKOFDefaultGameMode() +{ + NumCharactersPerTeam = 3; + + MaxDistance = 700.0f; + StartY = 250.0f; +} + +void AKOFDefaultGameMode::InitTeams() +{ + for (TSubclassOf CharacterTemplate : P1TeamTemplate) + { + AKOFBaseCharacter* Temp = GetWorld()->SpawnActor(CharacterTemplate, FVector(0.0f, -StartY, 204.6241f), FRotator(0.0f, 90.0f, 0.0f)); + if(Temp) + { + P1Team.Add(Temp); + } + } + + for (TSubclassOf CharacterTemplate : P2TeamTemplate) + { + AKOFBaseCharacter* Temp = GetWorld()->SpawnActor(CharacterTemplate, FVector(0.0f, StartY, 204.6241f), FRotator(0.0f, -90.0f, 0.0f)); + Temp->AutoPossessPlayer = EAutoReceiveInput::Player1; + if(Temp) + { + P2Team.Add(Temp); + } + } +} + +void AKOFDefaultGameMode::StartPlay() +{ + Super::StartPlay(); + + InitTeams(); + + // is this the right place to do this? + APlayerController* PC1 = UGameplayStatics::GetPlayerController(GetWorld(), 0); + if(PC1) + { + AKOFBaseCharacter* P1 = GetP1CurrentCharacter(); + if(P1) + { + PC1->Possess(P1); + } + } + + APlayerController* PC2 = UGameplayStatics::GetPlayerController(GetWorld(), 1); + if(PC2) + { + AKOFBaseCharacter* P2 = GetP1CurrentCharacter(); + if(P2) + { + PC2->Possess(P2); + } + } +} diff --git a/KOFForever/Source/KOFForever/Private/GameModes/KOFTeam.cpp b/KOFForever/Source/KOFForever/Private/GameModes/KOFTeam.cpp new file mode 100644 index 0000000..1da4237 --- /dev/null +++ b/KOFForever/Source/KOFForever/Private/GameModes/KOFTeam.cpp @@ -0,0 +1,23 @@ + + + +#include "GameModes/KOFTeam.h" + +#include "Character/KOFBaseCharacter.h" + +AKOFBaseCharacter* UKOFTeam::GetCurrentCharacter() +{ + return Characters.Num() > 0 ? Characters[0] : nullptr; +} + +void UKOFTeam::InitTeam() +{ + for (TSubclassOf CharacterTemplate : CharacterTemplates) + { + AKOFBaseCharacter* Temp = NewObject(CharacterTemplate); + if(Temp) + { + Characters.Add(Temp); + } + } +} diff --git a/KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h b/KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h index 1a48a6c..243cc84 100644 --- a/KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h +++ b/KOFForever/Source/KOFForever/Public/Camera/KOFDefaultCamera.h @@ -44,13 +44,10 @@ protected: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = CameraSettings) float ZAveragingFactor; - - // References to player main character's - // eventually we want to spawn all the player's characters from game mode? and then we can get the references to - // P1 and P2 from there. For now we'll just set the references manually in the level - UPROPERTY(EditAnywhere) - AActor* P1; + /** + * How far the character's have to be apart before the camera moves to keep both in frame + */ + float MovementYDistanceThreshold; - UPROPERTY(EditAnywhere) - AActor* P2; + void UpdateCamera(); }; diff --git a/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h b/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h new file mode 100644 index 0000000..700e020 --- /dev/null +++ b/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h @@ -0,0 +1,62 @@ + + +#pragma once + +#include "CoreMinimal.h" +#include "KOFTeam.h" +#include "Character/KOFBaseCharacter.h" +#include "GameFramework/GameModeBase.h" +#include "KOFDefaultGameMode.generated.h" + +/** + * + */ +UCLASS() +class KOFFOREVER_API AKOFDefaultGameMode : public AGameModeBase +{ + GENERATED_BODY() + +public: + AKOFDefaultGameMode(); + + TArray& GetP1Team() { return P1Team; } + + TArray& GetP2Team() { return P2Team; } + + // this will need to change when we actually have real time character switching + AKOFBaseCharacter* GetP1CurrentCharacter() { return P1Team.Num() > 0 ? P1Team[0] : nullptr; } + + // this will need to change when we actually have real time character switching + AKOFBaseCharacter* GetP2CurrentCharacter() { return P2Team.Num() > 0 ? P2Team[0] : nullptr; } + +protected: + /** Number of characters on a single player's team */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Settings|Team") + int32 NumCharactersPerTeam; + + /** Max distance the currently controlled player characters can be from one another */ + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings|Stage") + float MaxDistance; + + /** Y offset from origin where character's will be spawned */ + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings|Stage") + float StartY; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings|Team") + TArray> P1TeamTemplate; + + /** List of references to the player's team members */ + UPROPERTY(BlueprintReadOnly) + TArray P1Team; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Settings|Team") + TArray> P2TeamTemplate; + + /** List of references to the player's team members */ + UPROPERTY(BlueprintReadOnly) + TArray P2Team; + + void InitTeams(); + + virtual void StartPlay() override; +}; diff --git a/KOFForever/Source/KOFForever/Public/GameModes/KOFTeam.h b/KOFForever/Source/KOFForever/Public/GameModes/KOFTeam.h new file mode 100644 index 0000000..e5653c4 --- /dev/null +++ b/KOFForever/Source/KOFForever/Public/GameModes/KOFTeam.h @@ -0,0 +1,38 @@ + + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/NoExportTypes.h" +#include "KOFTeam.generated.h" + +class AKOFBaseCharacter; +/** + * + */ +UCLASS(BlueprintType, Blueprintable) +class KOFFOREVER_API UKOFTeam : public UObject +{ + GENERATED_BODY() + +public: + /** + * Returns the character on this team that is currently on stage being controlled by the player + */ + AKOFBaseCharacter* GetCurrentCharacter(); + + void InitTeam(); + +protected: + /** + * List of character templates to spawn the player's team when the match begins. + * + * This will eventually get set by the player's choices in the character select menu + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Characters") + TArray> CharacterTemplates; + + /** List of references to the player's team members */ + UPROPERTY(BlueprintReadOnly, Category="Characters") + TArray Characters; +}; From 0942a3a1c6382eec09398d4e89e784d7fbe5bb34 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 16 Jan 2022 21:38:43 -0500 Subject: [PATCH 3/4] Clamp position when character's reach max distance apart so they are always in camera view Clamp position when character's reach max distance apart so they are always in camera view --- .../Private/Character/KOFBaseCharacter.cpp | 32 +++----- .../KOFCharacterMovementComponent.cpp | 76 +++++++++++++++++++ .../Private/GameModes/KOFDefaultGameMode.cpp | 5 +- .../Public/Character/KOFBaseCharacter.h | 19 ++++- .../KOFCharacterMovementComponent.h | 22 ++++++ .../Public/GameModes/KOFDefaultGameMode.h | 6 +- 6 files changed, 133 insertions(+), 27 deletions(-) create mode 100644 KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp create mode 100644 KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h diff --git a/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp b/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp index 000fc00..0ba3926 100644 --- a/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp +++ b/KOFForever/Source/KOFForever/Private/Character/KOFBaseCharacter.cpp @@ -8,17 +8,20 @@ #include "GameFramework/CharacterMovementComponent.h" #include "GameFramework/SpringArmComponent.h" #include "PaperFlipbookComponent.h" +#include "Componenets/KOFCharacterMovementComponent.h" +#include "GameModes/KOFDefaultGameMode.h" DEFINE_LOG_CATEGORY_STATIC(SideScrollerCharacter, Log, All); ////////////////////////////////////////////////////////////////////////// // ASideScroller2DCharacter -AKOFBaseCharacter::AKOFBaseCharacter() +AKOFBaseCharacter::AKOFBaseCharacter(const FObjectInitializer& ObjectInitializer) + : Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName)) { // Use only Yaw from the controller and ignore the rest of the rotation. bUseControllerRotationPitch = false; - bUseControllerRotationYaw = true; + bUseControllerRotationYaw = false; bUseControllerRotationRoll = false; // Set the size of our collision capsule. @@ -29,7 +32,7 @@ AKOFBaseCharacter::AKOFBaseCharacter() // Configure character movement GetCharacterMovement()->GravityScale = 2.0f; - GetCharacterMovement()->AirControl = 0.80f; + GetCharacterMovement()->AirControl = 0.0f; GetCharacterMovement()->JumpZVelocity = 1000.f; GetCharacterMovement()->GroundFriction = 3.0f; GetCharacterMovement()->MaxWalkSpeed = 600.0f; @@ -150,7 +153,7 @@ void AKOFBaseCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerI void AKOFBaseCharacter::MoveRight(float Value) { /*UpdateChar();*/ - + // Apply the input to the character motion AddMovementInput(FVector(0.0f, 1.0f, 0.0f), Value); } @@ -159,22 +162,5 @@ void AKOFBaseCharacter::UpdateCharacter() { // Update animation to match the motion UpdateAnimation(); - - /* - // Now setup the rotation of the controller based on the direction we are travelling - const FVector PlayerVelocity = GetVelocity(); - float TravelDirection = PlayerVelocity.Y; - // Set the rotation so that the character faces his direction of travel. - if (Controller != nullptr) - { - if (TravelDirection < 0.0f) - { - Controller->SetControlRotation(FRotator(0.0, -90.0f, 0.0f)); - } - else if (TravelDirection > 0.0f) - { - Controller->SetControlRotation(FRotator(0.0f, 90.0f, 0.0)); - } - } - */ -} \ No newline at end of file +} + \ No newline at end of file diff --git a/KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp b/KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp new file mode 100644 index 0000000..87f401e --- /dev/null +++ b/KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp @@ -0,0 +1,76 @@ + + + +#include "Componenets/KOFCharacterMovementComponent.h" + +#include "GameModes/KOFDefaultGameMode.h" + +UKOFCharacterMovementComponent::UKOFCharacterMovementComponent() +{ + PrimaryComponentTick.bCanEverTick = true; +} + +void UKOFCharacterMovementComponent::TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + AKOFBaseCharacter* Owner = Cast(GetOwner()); + if(!Owner) + { + UE_LOG(LogTemp, Error, TEXT("AKOFCharacterMovementComponent::PostPhysicsTickComponent - could not get the owner")); + return; + } + + AKOFDefaultGameMode* GameMode = Cast(GetWorld()->GetAuthGameMode()); + if(!GameMode) + { + UE_LOG(LogTemp, Error, TEXT("AKOFCharacterMovementComponent::PostPhysicsTickComponent - could not get the game mode")); + return; + } + + AKOFBaseCharacter* Opponent = GameMode->GetCurrentOpponent(Owner->IsPossessedByPlayer1()); + if(Opponent) + { + float HalfYDistance = GameMode->GetMaxAllowedDistanceFromOpponent() / 2.0f; + float YMidpoint = (Owner->GetActorLocation().Y + Opponent->GetActorLocation().Y) / 2.0f; + + float AdjustedY = FMath::Clamp(Owner->GetActorLocation().Y, YMidpoint - HalfYDistance, YMidpoint + HalfYDistance); + + FVector CurrentLoc = Owner->GetActorLocation(); + Owner->SetActorLocation(FVector(CurrentLoc.X, AdjustedY, CurrentLoc.Z)); + } +} + +void UKOFCharacterMovementComponent::PostPhysicsTickComponent(float DeltaTime, + FCharacterMovementComponentPostPhysicsTickFunction& ThisTickFunction) +{ + Super::PostPhysicsTickComponent(DeltaTime, ThisTickFunction); + + AKOFBaseCharacter* Owner = Cast(GetOwner()); + if(!Owner) + { + UE_LOG(LogTemp, Error, TEXT("AKOFCharacterMovementComponent::PostPhysicsTickComponent - could not get the owner")); + return; + } + + AKOFDefaultGameMode* GameMode = Cast(GetWorld()->GetAuthGameMode()); + if(!GameMode) + { + UE_LOG(LogTemp, Error, TEXT("AKOFCharacterMovementComponent::PostPhysicsTickComponent - could not get the game mode")); + return; + } + + AKOFBaseCharacter* Opponent = GameMode->GetCurrentOpponent(Owner->IsPossessedByPlayer1()); + if(Opponent) + { + float YDistance = FMath::Abs(Opponent->GetActorLocation().Y - Owner->GetActorLocation().Y); + float HalfYDistance = YDistance / 2.0f; + float YMidpoint = (Owner->GetActorLocation().Y + Opponent->GetActorLocation().Y) / 2.0f; + + float AdjustedY = FMath::Clamp(Owner->GetActorLocation().Y, YMidpoint - HalfYDistance, YMidpoint + HalfYDistance); + + FVector CurrentLoc = Owner->GetActorLocation(); + Owner->SetActorLocation(FVector(CurrentLoc.X, AdjustedY, CurrentLoc.Z)); + } +} diff --git a/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp b/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp index cb54cbd..5b91d5e 100644 --- a/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp +++ b/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp @@ -9,7 +9,7 @@ AKOFDefaultGameMode::AKOFDefaultGameMode() { NumCharactersPerTeam = 3; - MaxDistance = 700.0f; + MaxAllowedDistanceFromOpponent = 700.0f; StartY = 250.0f; } @@ -18,6 +18,7 @@ void AKOFDefaultGameMode::InitTeams() for (TSubclassOf CharacterTemplate : P1TeamTemplate) { AKOFBaseCharacter* Temp = GetWorld()->SpawnActor(CharacterTemplate, FVector(0.0f, -StartY, 204.6241f), FRotator(0.0f, 90.0f, 0.0f)); + Temp->SetIsPossesedByPlayer1(true); if(Temp) { P1Team.Add(Temp); @@ -27,7 +28,7 @@ void AKOFDefaultGameMode::InitTeams() for (TSubclassOf CharacterTemplate : P2TeamTemplate) { AKOFBaseCharacter* Temp = GetWorld()->SpawnActor(CharacterTemplate, FVector(0.0f, StartY, 204.6241f), FRotator(0.0f, -90.0f, 0.0f)); - Temp->AutoPossessPlayer = EAutoReceiveInput::Player1; + Temp->SetIsPossesedByPlayer1(false); if(Temp) { P2Team.Add(Temp); diff --git a/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h b/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h index e9f7099..21fb04f 100644 --- a/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h +++ b/KOFForever/Source/KOFForever/Public/Character/KOFBaseCharacter.h @@ -51,6 +51,9 @@ protected: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Animations) class UPaperFlipbook* IdleAnimation; + UPROPERTY(BlueprintReadOnly) + bool bIsPossesedByPlayer1; + /** Called to choose the correct animation to play based on the character's movement state */ void UpdateAnimation(); @@ -64,7 +67,21 @@ protected: // End of APawn interface public: - AKOFBaseCharacter(); + AKOFBaseCharacter(const FObjectInitializer& ObjectInitializer); FORCEINLINE class UPaperFlipbookComponent* GetShadow() const { return Shadow; } + + /** + * Returns whether or not this player is possessed by player 1 + * + * @returns true is possessed by player 1, false if possessed by player 2 + */ + FORCEINLINE bool IsPossessedByPlayer1() const { return bIsPossesedByPlayer1; } + + /** + * Sets which player this character is possesed by. + * + * @param bIsPlayer1 true is possessed by player 1, false if possessed by player 2 + */ + FORCEINLINE void SetIsPossesedByPlayer1(bool bIsPlayer1) { bIsPossesedByPlayer1 = bIsPlayer1; } }; diff --git a/KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h b/KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h new file mode 100644 index 0000000..d1c789c --- /dev/null +++ b/KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h @@ -0,0 +1,22 @@ + + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/CharacterMovementComponent.h" +#include "KOFCharacterMovementComponent.generated.h" + +/** + * + */ +UCLASS() +class KOFFOREVER_API UKOFCharacterMovementComponent : public UCharacterMovementComponent +{ + GENERATED_BODY() + + UKOFCharacterMovementComponent(); + + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + + virtual void PostPhysicsTickComponent(float DeltaTime, FCharacterMovementComponentPostPhysicsTickFunction& ThisTickFunction) override; +}; diff --git a/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h b/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h index 700e020..4a21c11 100644 --- a/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h +++ b/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h @@ -28,6 +28,10 @@ public: // this will need to change when we actually have real time character switching AKOFBaseCharacter* GetP2CurrentCharacter() { return P2Team.Num() > 0 ? P2Team[0] : nullptr; } + + AKOFBaseCharacter* GetCurrentOpponent(bool bIsPlayer1) { return bIsPlayer1 ? GetP2CurrentCharacter() : GetP1CurrentCharacter(); } + + FORCEINLINE float GetMaxAllowedDistanceFromOpponent() { return MaxAllowedDistanceFromOpponent; } protected: /** Number of characters on a single player's team */ @@ -36,7 +40,7 @@ protected: /** Max distance the currently controlled player characters can be from one another */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings|Stage") - float MaxDistance; + float MaxAllowedDistanceFromOpponent; /** Y offset from origin where character's will be spawned */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings|Stage") From 6d3b189234d16ab6ec891972511eb34899585667 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 17 Jan 2022 14:56:25 -0500 Subject: [PATCH 4/4] Clamp character and camera position to stage boundaries Clamp character and camera position to stage boundaries --- KOFForever/Content/Maps/DebugStage.umap | 4 +- .../Private/Camera/KOFDefaultCamera.cpp | 6 ++- .../KOFCharacterMovementComponent.cpp | 40 ++++--------------- .../Private/GameModes/KOFDefaultGameMode.cpp | 1 + .../KOFCharacterMovementComponent.h | 2 - .../Public/GameModes/KOFDefaultGameMode.h | 5 +++ 6 files changed, 19 insertions(+), 39 deletions(-) diff --git a/KOFForever/Content/Maps/DebugStage.umap b/KOFForever/Content/Maps/DebugStage.umap index 9fa925c..0f2842d 100644 --- a/KOFForever/Content/Maps/DebugStage.umap +++ b/KOFForever/Content/Maps/DebugStage.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0734c34f22596584ab16ae499c6df6869ce893efc067598c4e80b8a451b6677d -size 8531398 +oid sha256:743fbea5cf9687ba65781c185871af056bec291a110e2adb760de694f1ea94e4 +size 8528916 diff --git a/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp b/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp index 16ae7c2..0699074 100644 --- a/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp +++ b/KOFForever/Source/KOFForever/Private/Camera/KOFDefaultCamera.cpp @@ -7,6 +7,7 @@ #include "Camera/CameraComponent.h" #include "Character/KOFBaseCharacter.h" #include "GameModes/KOFDefaultGameMode.h" +#include "Kismet/GameplayStatics.h" AKOFDefaultCamera::AKOFDefaultCamera() { @@ -41,8 +42,9 @@ void AKOFDefaultCamera::Tick(float DeltaSeconds) FVector P1Loc = P1->GetActorLocation(); FVector P2Loc = P2->GetActorLocation(); FVector CameraLoc = GetActorLocation(); - - FVector MidPoint = FVector(CameraLoc.X, (P1Loc.Y + P2Loc.Y) / 2.0f, ((P1Loc.Z + P2Loc.Z) / ZAveragingFactor) + HeightOffset); + + float HalfStageLength = GameMode->GetStageLength() / 2.0f; + FVector MidPoint = FVector(CameraLoc.X, FMath::Clamp((P1Loc.Y + P2Loc.Y) / 2.0f, -HalfStageLength, HalfStageLength), ((P1Loc.Z + P2Loc.Z) / ZAveragingFactor) + HeightOffset); SetActorLocation(MidPoint); // set FOV diff --git a/KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp b/KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp index 87f401e..2406845 100644 --- a/KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp +++ b/KOFForever/Source/KOFForever/Private/Componenets/KOFCharacterMovementComponent.cpp @@ -40,37 +40,11 @@ void UKOFCharacterMovementComponent::TickComponent(float DeltaTime, ELevelTick T FVector CurrentLoc = Owner->GetActorLocation(); Owner->SetActorLocation(FVector(CurrentLoc.X, AdjustedY, CurrentLoc.Z)); } -} - -void UKOFCharacterMovementComponent::PostPhysicsTickComponent(float DeltaTime, - FCharacterMovementComponentPostPhysicsTickFunction& ThisTickFunction) -{ - Super::PostPhysicsTickComponent(DeltaTime, ThisTickFunction); - - AKOFBaseCharacter* Owner = Cast(GetOwner()); - if(!Owner) - { - UE_LOG(LogTemp, Error, TEXT("AKOFCharacterMovementComponent::PostPhysicsTickComponent - could not get the owner")); - return; - } - - AKOFDefaultGameMode* GameMode = Cast(GetWorld()->GetAuthGameMode()); - if(!GameMode) - { - UE_LOG(LogTemp, Error, TEXT("AKOFCharacterMovementComponent::PostPhysicsTickComponent - could not get the game mode")); - return; - } - - AKOFBaseCharacter* Opponent = GameMode->GetCurrentOpponent(Owner->IsPossessedByPlayer1()); - if(Opponent) - { - float YDistance = FMath::Abs(Opponent->GetActorLocation().Y - Owner->GetActorLocation().Y); - float HalfYDistance = YDistance / 2.0f; - float YMidpoint = (Owner->GetActorLocation().Y + Opponent->GetActorLocation().Y) / 2.0f; - - float AdjustedY = FMath::Clamp(Owner->GetActorLocation().Y, YMidpoint - HalfYDistance, YMidpoint + HalfYDistance); - - FVector CurrentLoc = Owner->GetActorLocation(); - Owner->SetActorLocation(FVector(CurrentLoc.X, AdjustedY, CurrentLoc.Z)); - } + + // clamp to stage bounds + FVector CurrentLoc = Owner->GetActorLocation(); + float HalfStageLength = GameMode->GetStageLength() / 2.0f; + Owner->SetActorLocation(FVector(CurrentLoc.X, + FMath::Clamp(CurrentLoc.Y, -HalfStageLength, HalfStageLength), + CurrentLoc.Z)); } diff --git a/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp b/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp index 5b91d5e..23b62e5 100644 --- a/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp +++ b/KOFForever/Source/KOFForever/Private/GameModes/KOFDefaultGameMode.cpp @@ -10,6 +10,7 @@ AKOFDefaultGameMode::AKOFDefaultGameMode() NumCharactersPerTeam = 3; MaxAllowedDistanceFromOpponent = 700.0f; + StageLength = 2400.0f; StartY = 250.0f; } diff --git a/KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h b/KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h index d1c789c..1a57391 100644 --- a/KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h +++ b/KOFForever/Source/KOFForever/Public/Componenets/KOFCharacterMovementComponent.h @@ -17,6 +17,4 @@ class KOFFOREVER_API UKOFCharacterMovementComponent : public UCharacterMovementC UKOFCharacterMovementComponent(); virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; - - virtual void PostPhysicsTickComponent(float DeltaTime, FCharacterMovementComponentPostPhysicsTickFunction& ThisTickFunction) override; }; diff --git a/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h b/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h index 4a21c11..a796ecc 100644 --- a/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h +++ b/KOFForever/Source/KOFForever/Public/GameModes/KOFDefaultGameMode.h @@ -32,6 +32,8 @@ public: AKOFBaseCharacter* GetCurrentOpponent(bool bIsPlayer1) { return bIsPlayer1 ? GetP2CurrentCharacter() : GetP1CurrentCharacter(); } FORCEINLINE float GetMaxAllowedDistanceFromOpponent() { return MaxAllowedDistanceFromOpponent; } + + FORCEINLINE float GetStageLength() { return StageLength; } protected: /** Number of characters on a single player's team */ @@ -42,6 +44,9 @@ protected: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings|Stage") float MaxAllowedDistanceFromOpponent; + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings|Stage") + float StageLength; + /** Y offset from origin where character's will be spawned */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Settings|Stage") float StartY;