From b55e7be272184a65ca3f129abe0a5ce3910d751c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20GABOLDE?= Date: Thu, 9 Nov 2023 18:33:16 +0100 Subject: [PATCH] remove useless classes --- .../GrapplingGravityCharacter.cpp | 130 ------------------ .../GrapplingGravityCharacter.h | 73 ---------- .../GrapplingGravityGameMode.cpp | 15 -- .../GrapplingGravityGameMode.h | 19 --- 4 files changed, 237 deletions(-) delete mode 100644 Source/GrapplingGravity/GrapplingGravityCharacter.cpp delete mode 100644 Source/GrapplingGravity/GrapplingGravityCharacter.h delete mode 100644 Source/GrapplingGravity/GrapplingGravityGameMode.cpp delete mode 100644 Source/GrapplingGravity/GrapplingGravityGameMode.h diff --git a/Source/GrapplingGravity/GrapplingGravityCharacter.cpp b/Source/GrapplingGravity/GrapplingGravityCharacter.cpp deleted file mode 100644 index fb58cae..0000000 --- a/Source/GrapplingGravity/GrapplingGravityCharacter.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#include "GrapplingGravityCharacter.h" -#include "Engine/LocalPlayer.h" -#include "Camera/CameraComponent.h" -#include "Components/CapsuleComponent.h" -#include "GameFramework/CharacterMovementComponent.h" -#include "GameFramework/SpringArmComponent.h" -#include "GameFramework/Controller.h" -#include "EnhancedInputComponent.h" -#include "EnhancedInputSubsystems.h" -#include "InputActionValue.h" - -DEFINE_LOG_CATEGORY(LogTemplateCharacter); - -////////////////////////////////////////////////////////////////////////// -// AGrapplingGravityCharacter - -AGrapplingGravityCharacter::AGrapplingGravityCharacter() -{ - // Set size for collision capsule - // GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f); - - // Don't rotate when the controller rotates. Let that just affect the camera. - bUseControllerRotationPitch = false; - bUseControllerRotationYaw = false; - bUseControllerRotationRoll = false; - - // Configure character movement - GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input... - GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate - - // Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint - // instead of recompiling to adjust them - GetCharacterMovement()->JumpZVelocity = 700.f; - GetCharacterMovement()->AirControl = 0.35f; - GetCharacterMovement()->MaxWalkSpeed = 500.f; - GetCharacterMovement()->MinAnalogWalkSpeed = 20.f; - GetCharacterMovement()->BrakingDecelerationWalking = 2000.f; - GetCharacterMovement()->BrakingDecelerationFalling = 1500.0f; - - // Create a camera boom (pulls in towards the player if there is a collision) - CameraBoom = CreateDefaultSubobject(TEXT("CameraBoom")); - CameraBoom->SetupAttachment(RootComponent); - CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character - CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller - - // Create a follow camera - FollowCamera = CreateDefaultSubobject(TEXT("FollowCamera")); - FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation - FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm - - // Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character) - // are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++) -} - -void AGrapplingGravityCharacter::BeginPlay() -{ - // Call the base class - Super::BeginPlay(); - - //Add Input Mapping Context - if (APlayerController* PlayerController = Cast(Controller)) - { - if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem(PlayerController->GetLocalPlayer())) - { - Subsystem->AddMappingContext(DefaultMappingContext, 0); - } - } -} - -////////////////////////////////////////////////////////////////////////// -// Input - -void AGrapplingGravityCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) -{ - // Set up action bindings - if (UEnhancedInputComponent* EnhancedInputComponent = Cast(PlayerInputComponent)) { - - // Jumping - EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump); - EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping); - - // Moving - EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AGrapplingGravityCharacter::Move); - - // Looking - EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AGrapplingGravityCharacter::Look); - } - else - { - UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this)); - } -} - -void AGrapplingGravityCharacter::Move(const FInputActionValue& Value) -{ - // input is a Vector2D - FVector2D MovementVector = Value.Get(); - - if (Controller != nullptr) - { - // find out which way is forward - const FRotator Rotation = Controller->GetControlRotation(); - const FRotator YawRotation(0, Rotation.Yaw, 0); - - // get forward vector - const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X); - - // get right vector - const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y); - - // add movement - AddMovementInput(ForwardDirection, MovementVector.Y); - AddMovementInput(RightDirection, MovementVector.X); - } -} - -void AGrapplingGravityCharacter::Look(const FInputActionValue& Value) -{ - // input is a Vector2D - FVector2D LookAxisVector = Value.Get(); - - if (Controller != nullptr) - { - // add yaw and pitch input to controller - AddControllerYawInput(LookAxisVector.X); - AddControllerPitchInput(LookAxisVector.Y); - } -} \ No newline at end of file diff --git a/Source/GrapplingGravity/GrapplingGravityCharacter.h b/Source/GrapplingGravity/GrapplingGravityCharacter.h deleted file mode 100644 index e4ebdcf..0000000 --- a/Source/GrapplingGravity/GrapplingGravityCharacter.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/Character.h" -#include "Logging/LogMacros.h" -#include "GrapplingGravityCharacter.generated.h" - -class USpringArmComponent; -class UCameraComponent; -class UInputMappingContext; -class UInputAction; -struct FInputActionValue; - -DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All); - -UCLASS(config=Game) -class AGrapplingGravityCharacter : public ACharacter -{ - GENERATED_BODY() - - /** Camera boom positioning the camera behind the character */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) - USpringArmComponent* CameraBoom; - - /** Follow camera */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) - UCameraComponent* FollowCamera; - - /** MappingContext */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) - UInputMappingContext* DefaultMappingContext; - - /** Jump Input Action */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) - UInputAction* JumpAction; - - /** Move Input Action */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) - UInputAction* MoveAction; - - /** Look Input Action */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) - UInputAction* LookAction; - -public: - AGrapplingGravityCharacter(); - - -protected: - - /** Called for movement input */ - void Move(const FInputActionValue& Value); - - /** Called for looking input */ - void Look(const FInputActionValue& Value); - - -protected: - // APawn interface - virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; - - // To add mapping context - virtual void BeginPlay(); - -public: - /** Returns CameraBoom subobject **/ - FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } - /** Returns FollowCamera subobject **/ - FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; } -}; - diff --git a/Source/GrapplingGravity/GrapplingGravityGameMode.cpp b/Source/GrapplingGravity/GrapplingGravityGameMode.cpp deleted file mode 100644 index 75b1689..0000000 --- a/Source/GrapplingGravity/GrapplingGravityGameMode.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#include "GrapplingGravityGameMode.h" -#include "GrapplingGravityCharacter.h" -#include "UObject/ConstructorHelpers.h" - -AGrapplingGravityGameMode::AGrapplingGravityGameMode() -{ - // set default pawn class to our Blueprinted character - static ConstructorHelpers::FClassFinder PlayerPawnBPClass(TEXT("/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter")); - if (PlayerPawnBPClass.Class != NULL) - { - DefaultPawnClass = PlayerPawnBPClass.Class; - } -} diff --git a/Source/GrapplingGravity/GrapplingGravityGameMode.h b/Source/GrapplingGravity/GrapplingGravityGameMode.h deleted file mode 100644 index b21407f..0000000 --- a/Source/GrapplingGravity/GrapplingGravityGameMode.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/GameModeBase.h" -#include "GrapplingGravityGameMode.generated.h" - -UCLASS(minimalapi) -class AGrapplingGravityGameMode : public AGameModeBase -{ - GENERATED_BODY() - -public: - AGrapplingGravityGameMode(); -}; - - -