Setup for character
movement not working
This commit is contained in:
9
Source/OpenConflict/DDIGamemodeBase.cpp
Normal file
9
Source/OpenConflict/DDIGamemodeBase.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DDIGamemodeBase.h"
|
||||
|
||||
void ADDIGamemodeBase::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
49
Source/OpenConflict/DDIGamemodeBase.h
Normal file
49
Source/OpenConflict/DDIGamemodeBase.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/GameModeBase.h"
|
||||
#include "DDIGamemodeBase.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class OPENCONFLICT_API ADDIGamemodeBase : public AGameModeBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
/*UPROPERTY and UFUNCTION declarations*/
|
||||
private:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
protected:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
public:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
|
||||
/*C++ only declarations*/
|
||||
private:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
protected:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
};
|
||||
10
Source/OpenConflict/PlayerCharacter/DDICameraManager.cpp
Normal file
10
Source/OpenConflict/PlayerCharacter/DDICameraManager.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DDICameraManager.h"
|
||||
|
||||
ADDICameraManager::ADDICameraManager()
|
||||
{
|
||||
ViewPitchMin = -70.f;
|
||||
ViewPitchMax = 80.f;
|
||||
}
|
||||
20
Source/OpenConflict/PlayerCharacter/DDICameraManager.h
Normal file
20
Source/OpenConflict/PlayerCharacter/DDICameraManager.h
Normal file
@@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Camera/PlayerCameraManager.h"
|
||||
#include "DDICameraManager.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class ADDICameraManager : public APlayerCameraManager
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
ADDICameraManager();
|
||||
|
||||
};
|
||||
339
Source/OpenConflict/PlayerCharacter/DDICharacter.cpp
Normal file
339
Source/OpenConflict/PlayerCharacter/DDICharacter.cpp
Normal file
@@ -0,0 +1,339 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DDICharacter.h"
|
||||
|
||||
// #include "DDIWeapon.h"
|
||||
#include "Animation/AnimInstance.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/SkeletalMeshComponent.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "InputActionValue.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogTemplateCharacter);
|
||||
|
||||
// Sets default values
|
||||
ADDICharacter::ADDICharacter()
|
||||
{
|
||||
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = false;
|
||||
|
||||
isPaused = false;
|
||||
|
||||
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.f);
|
||||
|
||||
// Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("FirstPersonMesh"));
|
||||
|
||||
// Mesh->SetupAttachment(GetMesh());
|
||||
GetMesh()->SetOnlyOwnerSee(true);
|
||||
GetMesh()->FirstPersonPrimitiveType = EFirstPersonPrimitiveType::FirstPerson;
|
||||
GetMesh()->SetupAttachment(GetCapsuleComponent());
|
||||
// GetMesh()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
|
||||
FirstPersonCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("First Person Camera"));
|
||||
// FirstPersonCamera->SetupAttachment(FirstPersonMesh, FName("head"));
|
||||
FirstPersonCamera->SetRelativeLocationAndRotation(FVector(-2.8f, 5.89f, 0.0f), FRotator(0.0f, 90.0f, -90.0f));
|
||||
FirstPersonCamera->bUsePawnControlRotation = true;
|
||||
FirstPersonCamera->bEnableFirstPersonFieldOfView = true;
|
||||
FirstPersonCamera->bEnableFirstPersonScale = true;
|
||||
FirstPersonCamera->FirstPersonFieldOfView = 70.0f;
|
||||
FirstPersonCamera->FirstPersonScale = 0.6f;
|
||||
|
||||
// GetMesh()->SetOwnerNoSee(true);
|
||||
// GetMesh()->FirstPersonPrimitiveType = EFirstPersonPrimitiveType::WorldSpaceRepresentation;
|
||||
|
||||
GetCapsuleComponent()->SetCapsuleSize(34.f, 96.f);
|
||||
|
||||
GetCharacterMovement()->BrakingDecelerationFalling = 1500.f;
|
||||
GetCharacterMovement()->AirControl = 0.5f;
|
||||
GetCharacterMovement()->RotationRate = FRotator(0.0f, 600.0f, 0.0f);
|
||||
}
|
||||
ADDICharacter::~ADDICharacter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ADDICharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// SetupPlayerInputComponent( InputComponent);
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
void ADDICharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
{
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent))
|
||||
{
|
||||
// Jumping
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ADDICharacter::DoJumpStart);
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ADDICharacter::DoJumpEnd);
|
||||
|
||||
// Moving
|
||||
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ADDICharacter::MoveInput);
|
||||
|
||||
// Looking/Aiming
|
||||
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &ADDICharacter::LookInput);
|
||||
EnhancedInputComponent->BindAction(MouseLookAction, ETriggerEvent::Triggered, this, &ADDICharacter::LookInput);
|
||||
|
||||
// Firing
|
||||
// EnhancedInputComponent->BindAction(FireAction, ETriggerEvent::Started, this, &ADDICharacter::DoStartFiring);
|
||||
// EnhancedInputComponent->BindAction(FireAction, ETriggerEvent::Completed, this, &ADDICharacter::DoStopFiring);
|
||||
|
||||
// Switch weapon
|
||||
// EnhancedInputComponent->BindAction(SwitchWeaponAction, ETriggerEvent::Triggered, this, &ADDICharacter::DoSwitchWeapon);
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "SetupPlayerInputComponent");
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
float ADDICharacter::TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
|
||||
{
|
||||
// ignore if already dead
|
||||
if (CurrentHP <= 0.0f)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
// Reduce HP
|
||||
CurrentHP -= Damage;
|
||||
|
||||
// Have we depleted HP?
|
||||
if (CurrentHP <= 0.0f)
|
||||
{
|
||||
// deactivate the weapon
|
||||
// if (IsValid(CurrentWeapon))
|
||||
// {
|
||||
// CurrentWeapon->DeactivateWeapon();
|
||||
// }
|
||||
|
||||
|
||||
// reset the bullet counter UI
|
||||
// OnBulletCountUpdated.Broadcast(0, 0);
|
||||
|
||||
// destroy this character
|
||||
Destroy();
|
||||
}
|
||||
|
||||
return Damage;
|
||||
}
|
||||
|
||||
// void ADDICharacter::DoStartFiring()
|
||||
// {
|
||||
// // fire the current weapon
|
||||
// if (CurrentWeapon)
|
||||
// {
|
||||
// CurrentWeapon->StartFiring();
|
||||
// }
|
||||
// }
|
||||
|
||||
// void ADDICharacter::DoStopFiring()
|
||||
// {
|
||||
// // stop firing the current weapon
|
||||
// if (CurrentWeapon)
|
||||
// {
|
||||
// CurrentWeapon->StopFiring();
|
||||
// }
|
||||
// }
|
||||
|
||||
// void ADDICharacter::DoSwitchWeapon()
|
||||
// {
|
||||
// // ensure we have at least two weapons two switch between
|
||||
// if (OwnedWeapons.Num() > 1)
|
||||
// {
|
||||
// // deactivate the old weapon
|
||||
// CurrentWeapon->DeactivateWeapon();
|
||||
//
|
||||
// // find the index of the current weapon in the owned list
|
||||
// int32 WeaponIndex = OwnedWeapons.Find(CurrentWeapon);
|
||||
//
|
||||
// // is this the last weapon?
|
||||
// if (WeaponIndex == OwnedWeapons.Num() - 1)
|
||||
// {
|
||||
// // loop back to the beginning of the array
|
||||
// WeaponIndex = 0;
|
||||
// }
|
||||
// else {
|
||||
// // select the next weapon index
|
||||
// ++WeaponIndex;
|
||||
// }
|
||||
//
|
||||
// // set the new weapon as current
|
||||
// CurrentWeapon = OwnedWeapons[WeaponIndex];
|
||||
//
|
||||
// // activate the new weapon
|
||||
// CurrentWeapon->ActivateWeapon();
|
||||
// }
|
||||
// }
|
||||
|
||||
void ADDICharacter::MoveInput(const FInputActionValue& Value)
|
||||
{
|
||||
// get the Vector2D move axis
|
||||
FVector2D MovementVector = Value.Get<FVector2D>();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "Move started");
|
||||
// pass the axis values to the move input
|
||||
DoMove(MovementVector.X, MovementVector.Y);
|
||||
}
|
||||
|
||||
void ADDICharacter::LookInput(const FInputActionValue& Value)
|
||||
{
|
||||
// get the Vector2D look axis
|
||||
FVector2D LookAxisVector = Value.Get<FVector2D>()*mouseSensitivity; //Added mouseSensitivity
|
||||
|
||||
// pass the axis values to the aim input
|
||||
DoAim(LookAxisVector.X, LookAxisVector.Y);
|
||||
|
||||
}
|
||||
|
||||
void ADDICharacter::DoAim(float Yaw, float Pitch)
|
||||
{
|
||||
if (GetController())
|
||||
{
|
||||
// pass the rotation inputs
|
||||
AddControllerYawInput(Yaw);
|
||||
AddControllerPitchInput(Pitch);
|
||||
}
|
||||
}
|
||||
|
||||
void ADDICharacter::DoMove(float Right, float Forward)
|
||||
{
|
||||
if (GetController())
|
||||
{
|
||||
// pass the move inputs
|
||||
AddMovementInput(GetActorRightVector(), Right);
|
||||
AddMovementInput(GetActorForwardVector(), Forward);
|
||||
}
|
||||
}
|
||||
|
||||
void ADDICharacter::DoJumpStart()
|
||||
{
|
||||
// pass Jump to the character
|
||||
Jump();
|
||||
}
|
||||
|
||||
void ADDICharacter::DoJumpEnd()
|
||||
{
|
||||
// pass StopJumping to the character
|
||||
StopJumping();
|
||||
}
|
||||
|
||||
// void ADDICharacter::AttachWeaponMeshes(ADDIWeapon* Weapon)
|
||||
// {
|
||||
// const FAttachmentTransformRules AttachmentRule(EAttachmentRule::SnapToTarget, false);
|
||||
//
|
||||
// // attach the weapon actor
|
||||
// Weapon->AttachToActor(this, AttachmentRule);
|
||||
//
|
||||
// // attach the weapon meshes
|
||||
// Weapon->GetFirstPersonMesh()->AttachToComponent(GetFirstPersonMesh(), AttachmentRule, FirstPersonWeaponSocket);
|
||||
// Weapon->GetThirdPersonMesh()->AttachToComponent(GetMesh(), AttachmentRule, FirstPersonWeaponSocket);
|
||||
//
|
||||
// }
|
||||
|
||||
// void ADDICharacter::PlayFiringMontage(UAnimMontage* Montage)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
// void ADDICharacter::AddWeaponRecoil(float Recoil)
|
||||
// {
|
||||
// // apply the recoil as pitch input
|
||||
// AddControllerPitchInput(Recoil);
|
||||
// }
|
||||
|
||||
// void ADDICharacter::UpdateWeaponHUD(int32 CurrentAmmo, int32 MagazineSize)
|
||||
// {
|
||||
// OnBulletCountUpdated.Broadcast(MagazineSize, CurrentAmmo);
|
||||
// }
|
||||
|
||||
// FVector ADDICharacter::GetWeaponTargetLocation()
|
||||
// {
|
||||
// // trace ahead from the camera viewpoint
|
||||
// FHitResult OutHit;
|
||||
//
|
||||
// const FVector Start = GetFirstPersonCameraComponent()->GetComponentLocation();
|
||||
// const FVector End = Start + (GetFirstPersonCameraComponent()->GetForwardVector() * MaxAimDistance);
|
||||
//
|
||||
// FCollisionQueryParams QueryParams;
|
||||
// QueryParams.AddIgnoredActor(this);
|
||||
//
|
||||
// GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, QueryParams);
|
||||
//
|
||||
// // return either the impact point or the trace end
|
||||
// return OutHit.bBlockingHit ? OutHit.ImpactPoint : OutHit.TraceEnd;
|
||||
// }
|
||||
|
||||
// void ADDICharacter::AddWeaponClass(const TSubclassOf<ADDIWeapon>& WeaponClass)
|
||||
// {
|
||||
// // do we already own this weapon?
|
||||
// ADDIWeapon* OwnedWeapon = FindWeaponOfType(WeaponClass);
|
||||
//
|
||||
// if (!OwnedWeapon)
|
||||
// {
|
||||
// // spawn the new weapon
|
||||
// FActorSpawnParameters SpawnParams;
|
||||
// SpawnParams.Owner = this;
|
||||
// SpawnParams.Instigator = this;
|
||||
// SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
// SpawnParams.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot;
|
||||
//
|
||||
// ADDIWeapon* AddedWeapon = GetWorld()->SpawnActor<ADDIWeapon>(WeaponClass, GetActorTransform(), SpawnParams);
|
||||
//
|
||||
// if (AddedWeapon)
|
||||
// {
|
||||
// // add the weapon to the owned list
|
||||
// OwnedWeapons.Add(AddedWeapon);
|
||||
//
|
||||
// // if we have an existing weapon, deactivate it
|
||||
// if (CurrentWeapon)
|
||||
// {
|
||||
// CurrentWeapon->DeactivateWeapon();
|
||||
// }
|
||||
//
|
||||
// // switch to the new weapon
|
||||
// CurrentWeapon = AddedWeapon;
|
||||
// CurrentWeapon->ActivateWeapon();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void ADDICharacter::OnWeaponActivated(ADDIWeapon* Weapon)
|
||||
// {
|
||||
// // update the bullet counter
|
||||
// OnBulletCountUpdated.Broadcast(Weapon->GetMagazineSize(), Weapon->GetMagCount());
|
||||
//
|
||||
// // set the character mesh AnimInstances
|
||||
// GetFirstPersonMesh()->SetAnimInstanceClass(Weapon->GetFirstPersonAnimInstanceClass());
|
||||
// GetMesh()->SetAnimInstanceClass(Weapon->GetThirdPersonAnimInstanceClass());
|
||||
// }
|
||||
|
||||
// void ADDICharacter::OnWeaponDeactivated(ADDIWeapon* Weapon)
|
||||
// {
|
||||
// // unused
|
||||
// }
|
||||
|
||||
// void ADDICharacter::OnSemiWeaponRefire()
|
||||
// {
|
||||
// // unused
|
||||
// }
|
||||
|
||||
// ADDIWeapon* ADDICharacter::FindWeaponOfType(TSubclassOf<ADDIWeapon> WeaponClass) const
|
||||
// {
|
||||
// // check each owned weapon
|
||||
// for (ADDIWeapon* Weapon : OwnedWeapons)
|
||||
// {
|
||||
// if (Weapon->IsA(WeaponClass))
|
||||
// {
|
||||
// return Weapon;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // weapon not found
|
||||
// return nullptr;
|
||||
//
|
||||
// }
|
||||
150
Source/OpenConflict/PlayerCharacter/DDICharacter.h
Normal file
150
Source/OpenConflict/PlayerCharacter/DDICharacter.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
// #include "DDIWeaponHolder.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Logging/LogMacros.h"
|
||||
#include "DDICharacter.generated.h"
|
||||
|
||||
class UInputComponent;
|
||||
class USkeletalMeshComponent;
|
||||
class UCameraComponent;
|
||||
class UInputAction;
|
||||
struct FInputActionValue;
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All);
|
||||
// DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FBulletCountUpdatedDelegate, int32, MagazineSize, int32, Bullets);
|
||||
|
||||
UCLASS(abstract)
|
||||
class ADDICharacter : public ACharacter/*, public IDDIWeaponHolder*/
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
|
||||
USkeletalMeshComponent* FirstPersonMesh;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
|
||||
UCameraComponent* FirstPersonCamera;
|
||||
|
||||
protected:
|
||||
/** Name of the first person mesh weapon socket */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category ="Weapons")
|
||||
FName FirstPersonWeaponSocket = FName("SOC_hand_r");
|
||||
|
||||
/** Name of the third person mesh weapon socket */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category ="Weapons")
|
||||
FName ThirdPersonWeaponSocket = FName("SOC_hand_r");
|
||||
|
||||
/** Max distance to use for aim traces */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category ="Aim")
|
||||
float MaxAimDistance = 10000.0f;
|
||||
|
||||
/** Current HP remaining to this character */
|
||||
UPROPERTY(EditAnywhere, Category="Health")
|
||||
float CurrentHP = 500.0f;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
UInputAction* JumpAction;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
UInputAction* MoveAction;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
UInputAction* LookAction;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
UInputAction* MouseLookAction;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
UInputAction* FireAction;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
UInputAction* SwitchWeaponAction;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
virtual void DoJumpStart();
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
virtual void DoJumpEnd();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
virtual void DoMove(float Right, float Froward);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
virtual void DoAim(float Yaw, float Pitch);
|
||||
|
||||
public:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Pause")
|
||||
bool isPaused;
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Pause")
|
||||
bool isStoreMenuOpen;
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Game Settings")
|
||||
float mouseSensitivity;
|
||||
|
||||
// UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
// void DoStartFiring();
|
||||
// UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
// void DoStopFiring();
|
||||
// UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
// void DoSwitchWeapon();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
// TArray<ADDIWeapon*> OwnedWeapons;
|
||||
|
||||
// TObjectPtr<ADDIWeapon> CurrentWeapon;
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
|
||||
void MoveInput(const FInputActionValue& value);
|
||||
|
||||
void LookInput(const FInputActionValue& value);
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent( UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
// ADDIWeapon* FindWeaponOfType(TSubclassOf<ADDIWeapon> WeaponClass) const;
|
||||
|
||||
public:
|
||||
|
||||
// FBulletCountUpdatedDelegate OnBulletCountUpdated;
|
||||
|
||||
// Sets default values for this character's properties
|
||||
ADDICharacter();
|
||||
// Decontructor for Main Character Class
|
||||
virtual ~ADDICharacter();
|
||||
virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser) override;
|
||||
|
||||
USkeletalMeshComponent* GetFirstPersonMesh() const { return FirstPersonMesh; };
|
||||
|
||||
UCameraComponent* GetFirstPersonCameraComponent() const {return FirstPersonCamera; };
|
||||
|
||||
//~Begin IShooterWeaponHolder interface
|
||||
|
||||
/** Attaches a weapon's meshes to the owner */
|
||||
// virtual void AttachWeaponMeshes(ADDIWeapon* Weapon) override;
|
||||
|
||||
/** Plays the firing montage for the weapon */
|
||||
// virtual void PlayFiringMontage(UAnimMontage* Montage) override;
|
||||
|
||||
/** Applies weapon recoil to the owner */
|
||||
// virtual void AddWeaponRecoil(float Recoil) override;
|
||||
|
||||
/** Updates the weapon's HUD with the current ammo count */
|
||||
// virtual void UpdateWeaponHUD(int CurrentAmmo, int MagazineSize) override;
|
||||
|
||||
/** Calculates and returns the aim location for the weapon */
|
||||
// virtual FVector GetWeaponTargetLocation() override;
|
||||
|
||||
/** Gives a weapon of this class to the owner */
|
||||
// virtual void AddWeaponClass(const TSubclassOf<ADDIWeapon>& WeaponClass) override;
|
||||
|
||||
/** Activates the passed weapon */
|
||||
// virtual void OnWeaponActivated(ADDIWeapon* Weapon) override;
|
||||
|
||||
/** Deactivates the passed weapon */
|
||||
// virtual void OnWeaponDeactivated(ADDIWeapon* Weapon) override;
|
||||
|
||||
/** Notifies the owner that the weapon cooldown has expired and it's ready to shoot again */
|
||||
// virtual void OnSemiWeaponRefire() override;
|
||||
|
||||
//~End IShooterWeaponHolder interface
|
||||
|
||||
};
|
||||
57
Source/OpenConflict/PlayerCharacter/DDIPlayerController.cpp
Normal file
57
Source/OpenConflict/PlayerCharacter/DDIPlayerController.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DDIPlayerController.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "InputMappingContext.h"
|
||||
#include "DDICameraManager.h"
|
||||
#include "DDICharacter.h"
|
||||
// #include "UI/DDIWeaponUI.h"
|
||||
|
||||
ADDIPlayerController::ADDIPlayerController()
|
||||
{
|
||||
PlayerCameraManagerClass = ADDICameraManager::StaticClass();
|
||||
}
|
||||
|
||||
void ADDIPlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
|
||||
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer()))
|
||||
{
|
||||
for (UInputMappingContext* CurrentContext : DefaultMappingContexts)
|
||||
{
|
||||
Subsystem->AddMappingContext(CurrentContext, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ADDIPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// WeaponUI = CreateWidget<UDDIWeaponUI>(this, WeaponUIClass);
|
||||
// WeaponUI->AddToPlayerScreen(0);
|
||||
}
|
||||
|
||||
void ADDIPlayerController::OnPossess(APawn* InPawn)
|
||||
{
|
||||
Super::OnPossess(InPawn);
|
||||
|
||||
// is this a shooter character?
|
||||
if (ADDICharacter* DDICharacter = Cast<ADDICharacter>(InPawn))
|
||||
{
|
||||
// add the player tag
|
||||
DDICharacter->Tags.Add(PlayerPawnTag);
|
||||
|
||||
// subscribe to the pawn's bullet count updated delegate
|
||||
// DDICharacter->OnBulletCountUpdated.AddDynamic(this, &ADDIPlayerController::OnBulletCountUpdated);
|
||||
}
|
||||
}
|
||||
|
||||
// void ADDIPlayerController::OnBulletCountUpdated(int MagazineSize, int Bullets)
|
||||
// {
|
||||
// // update the UI
|
||||
// // WeaponUI->BP_UpdateBulletCounter(MagazineSize, Bullets);
|
||||
// }
|
||||
72
Source/OpenConflict/PlayerCharacter/DDIPlayerController.h
Normal file
72
Source/OpenConflict/PlayerCharacter/DDIPlayerController.h
Normal file
@@ -0,0 +1,72 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
// #include "ShootHouse/ShootHouseStore.h"
|
||||
#include "DDIPlayerController.generated.h"
|
||||
|
||||
// class UDDIWeaponUI;
|
||||
class UInputMappingContext;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(abstract)
|
||||
class OPENCONFLICT_API ADDIPlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
/*UPROPERTY and UFUNCTION declarations*/
|
||||
private:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
protected:
|
||||
/*Properties*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooter", meta = (AllowPrivateAccess = "true"))
|
||||
TArray<UInputMappingContext*> DefaultMappingContexts;
|
||||
|
||||
// UPROPERTY(EditAnywhere, Category="Shooter")
|
||||
// TSubclassOf<UDDIWeaponUI> WeaponUIClass;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Shooter")
|
||||
FName PlayerPawnTag = FName("Player");
|
||||
|
||||
|
||||
/*Functions*/
|
||||
// UFUNCTION()
|
||||
// void OnBulletCountUpdated(int MagSize, int MagCount);
|
||||
|
||||
public:
|
||||
/*Properties*/
|
||||
// UPROPERTY(EditAnywhere, Category="Shooter")
|
||||
// TSubclassOf<UShootHouseStore> StoreUIClass;
|
||||
// UPROPERTY(EditAnywhere,BlueprintReadWrite, Category="Shooter")
|
||||
// TObjectPtr<UShootHouseStore> StoreUI;
|
||||
|
||||
/*Functions*/
|
||||
|
||||
/*C++ only declarations*/
|
||||
private:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
protected:
|
||||
/*Properties*/
|
||||
// TObjectPtr<UDDIWeaponUI> WeaponUI;
|
||||
|
||||
/*Functions*/
|
||||
virtual void SetupInputComponent() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void OnPossess(APawn *InPawn) override;
|
||||
|
||||
public:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
ADDIPlayerController();
|
||||
|
||||
};
|
||||
34
Source/OpenConflict/PlayerCharacter/Hero/Hero.cpp
Normal file
34
Source/OpenConflict/PlayerCharacter/Hero/Hero.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Hero.h"
|
||||
|
||||
// Sets default values
|
||||
AHero::AHero()
|
||||
{
|
||||
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AHero::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AHero::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
void AHero::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
{
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
|
||||
}
|
||||
|
||||
29
Source/OpenConflict/PlayerCharacter/Hero/Hero.h
Normal file
29
Source/OpenConflict/PlayerCharacter/Hero/Hero.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Hero.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class OPENCONFLICT_API AHero : public ACharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
AHero();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
// MyPlayerController.cpp
|
||||
#include "HeroController.h"
|
||||
|
||||
17
Source/OpenConflict/PlayerCharacter/Hero/HeroController.h
Normal file
17
Source/OpenConflict/PlayerCharacter/Hero/HeroController.h
Normal file
@@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "HeroController.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class OPENCONFLICT_API AHeroController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user