Compare commits

...

3 Commits

Author SHA1 Message Date
fef6bd8e3e game mode 2025-08-28 20:31:52 -05:00
bcf4af827c enhanced input and movement logic 2025-08-28 20:11:10 -05:00
c69563f6a3 animation blueprints 2025-08-28 19:37:41 -05:00
21 changed files with 156 additions and 35 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -8,7 +8,7 @@ public class Aura : ModuleRules
{ {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" });
PrivateDependencyModuleNames.AddRange(new string[] { }); PrivateDependencyModuleNames.AddRange(new string[] { });

View File

@ -3,3 +3,35 @@
#include "Character/AuraCharacter.h" #include "Character/AuraCharacter.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/SpringArmComponent.h"
AAuraCharacter::AAuraCharacter()
{
SpringArm = CreateDefaultSubobject<USpringArmComponent>("SpringArm");
SpringArm->TargetArmLength = 700.f;
SpringArm->bEnableCameraLag = true;
SpringArm->CameraLagSpeed = 10;
SpringArm->bUsePawnControlRotation = false;
SpringArm->bInheritPitch = false;
SpringArm->bInheritRoll = false;
SpringArm->bInheritYaw = false;
SpringArm->SetRelativeRotation (FRotator (0.f, -45.f, 0.f));
SpringArm->SetupAttachment(GetRootComponent ());
Camera = CreateDefaultSubobject<UCameraComponent>("Camera");
Camera->bUsePawnControlRotation = false;
Camera->SetupAttachment(SpringArm);
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator (0.f, 400.f, 0.f);
GetCharacterMovement()->bConstrainToPlane = true;
GetCharacterMovement()->bSnapToPlaneAtStart = true;
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
}

View File

@ -0,0 +1,5 @@
// Copyright; GhostPacket Games
#include "Game/AuraGameModeBase.h"

View File

@ -0,0 +1,55 @@
// Copyright; GhostPacket Games
#include "Player/AuraPlayerController.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"
AAuraPlayerController::AAuraPlayerController()
{
bReplicates = true;
}
void AAuraPlayerController::BeginPlay()
{
Super::BeginPlay();
check(AuraContext); // checks it's set
UEnhancedInputLocalPlayerSubsystem *Subsystem = ULocalPlayer::GetSubsystem <UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer ());
check (Subsystem);
Subsystem->AddMappingContext (AuraContext, 0);
bShowMouseCursor = true;
DefaultMouseCursor = EMouseCursor::Default;
FInputModeGameAndUI InputModeData;
InputModeData.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock);
InputModeData.SetHideCursorDuringCapture(false);
SetInputMode (InputModeData);
}
void AAuraPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
UEnhancedInputComponent *EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(InputComponent);
EnhancedInputComponent->BindAction (MoveAction, ETriggerEvent::Triggered, this, &AAuraPlayerController::Move);
}
void AAuraPlayerController::Move(const FInputActionValue& InputActionValue)
{
const FVector2D InputAxisVector = InputActionValue.Get<FVector2D>();
const FRotator Rotation = GetControlRotation ();
const FRotator YawRotation(0.f, Rotation.Yaw, 0.f);
const FVector ForwardDirection = FRotationMatrix (YawRotation).GetUnitAxis(EAxis::X);
const FVector RightDirection = FRotationMatrix (YawRotation).GetUnitAxis (EAxis::Y);
APawn *ControlledPawn = GetPawn<APawn>();
if (!ControlledPawn)
return;
ControlledPawn->AddMovementInput(ForwardDirection, InputAxisVector.Y);
ControlledPawn->AddMovementInput(RightDirection, InputAxisVector.X);
}

View File

@ -6,12 +6,21 @@
#include "Character/AuraCharacterBase.h" #include "Character/AuraCharacterBase.h"
#include "AuraCharacter.generated.h" #include "AuraCharacter.generated.h"
/** class USpringArmComponent;
* class UCameraComponent;
*/
UCLASS() UCLASS()
class AURA_API AAuraCharacter : public AAuraCharacterBase class AURA_API AAuraCharacter : public AAuraCharacterBase
{ {
GENERATED_BODY() GENERATED_BODY()
public:
AAuraCharacter ();
private:
UPROPERTY (EditAnywhere)
TObjectPtr<USpringArmComponent> SpringArm;
UPROPERTY (EditAnywhere)
TObjectPtr<UCameraComponent> Camera;
}; };

View File

@ -0,0 +1,17 @@
// Copyright; GhostPacket Games
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "AuraGameModeBase.generated.h"
/**
*
*/
UCLASS()
class AURA_API AAuraGameModeBase : public AGameModeBase
{
GENERATED_BODY()
};

View File

@ -0,0 +1,34 @@
// Copyright; GhostPacket Games
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "AuraPlayerController.generated.h"
class UInputMappingContext;
class UInputAction;
struct FInputActionValue;
UCLASS()
class AURA_API AAuraPlayerController : public APlayerController
{
GENERATED_BODY()
public:
AAuraPlayerController ();
protected:
virtual void BeginPlay() override;
virtual void SetupInputComponent() override;
private:
UPROPERTY (EditAnywhere, Category = "Input")
TObjectPtr<UInputMappingContext> AuraContext;
UPROPERTY (EditAnywhere, Category = "Input")
TObjectPtr<UInputAction> MoveAction;
void Move (const FInputActionValue &InputActionValue);
};

View File

@ -1,19 +0,0 @@
// Copyright; GhostPacket Games
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "AuraCharacterBase.generated.h"
UCLASS(Abstract) // Abstract so that it cannot be dragged to a level
class AURA_API AAuraCharacterBase : public ACharacter
{
GENERATED_BODY()
public:
AAuraCharacterBase();
protected:
virtual void BeginPlay() override;
};

View File

@ -1,12 +0,0 @@
// Copyright; GhostPacket Games
#include "Character/AuraCharacterBase.h"
AAuraCharacterBase::AAuraCharacterBase()
{
PrimaryActorTick.bCanEverTick = false;
}
void AAuraCharacterBase::BeginPlay()
{
Super::BeginPlay();
}