FPSCharater.cpp
FPSCharater.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Weapons/Weapon.h"
#include "FPSCharater.generated.h"
UCLASS()
class TFSOVEREIGN_API AFPSCharater : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AFPSCharater();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
public:
// Called every frame
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components")
class UCameraComponent* Camera;
protected:
//The Weapon spawned by default
UPROPERTY(EditDefaultsOnly, Category = "Configurations")
TArray<TSubclassOf<class AWeapon>> DefaultWeapons;
public:
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Replicated, Category = "State")
TArray<class AWeapon*> Weapons;
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, ReplicatedUsing = OnRep_CurrentWeapon, Category = "State")
class AWeapon* CurrentWeapon;
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "State")
int32 CurrentIndex = 0;
protected:
UFUNCTION()
virtual void OnRep_CurrentWeapon(const class AWeapon* OldWeapon);
protected:
void MoveForward(const float Value);
void MoveRight(const float Value);
void LookUp(const float Value);
void LookRight(const float Value);;
};
Weapon.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Weapon.generated.h"
USTRUCT(BlueprintType)
struct FIKProperties
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UAnimSequence* Animpose;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float AimOffset = 15.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform CustomOffsetTransform;
};
UCLASS(Abstract)
class TFSovereign_API AWeapon : public AActor
{
GENERATED_BODY()
public:
AWeapon();
protected:
virtual void BeginPlay() override;
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Component")
class USceneComponent* Root;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Component")
class USkeletalMeshComponent* Mesh;
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "State")
class AFPSCharater* CurrentOwner;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Configureations")
FIKProperties IKProperties;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Configureations")
FTransform PlacementTransform;
};
Weapon.cpp
#include "Weapons/Weapon.h"
AWeapon::AWeapon()
{
PrimaryActorTick.bCanEverTick = false;
SetReplicates(true);
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent = Root;
Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(Text("Mesh"));
Mesh->SetupAttachment(Root);
}
void AWeapon::BeginPlay()
{
Super::BeginPlay();
Mesh->SetVisibility(false);
}
1>D:/Game Dev/UE5/TFSovereign/Source/TFSovereign/Public/FPSCharater.h(42): error : 1>Creating makefile for TFSovereignEditor (no existing makefile)
1>Parsing headers for TFSovereignEditor
1> Running UnrealHeaderTool “D:\Game Dev\UE5\TFSovereign\TFSovereign.uproject” “D:\Game Dev\UE5\TFSovereign\Intermediate\Build\Win64\TFSovereignEditor\Development\TFSovereignEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog=“C:\Users\richi\AppData\Local\UnrealBuildTool\Log_UHT.txt” -installed
1>D:/Game Dev/UE5/TFSovereign/Source/TFSovereign/Public/FPSCharater.h(42): error : Class ‘AWeapon’ not found.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(45,5): error MSB3073: The command ““D:\Game Dev\UE_5.0\Engine\Build\BatchFiles\Build.bat” TFSovereignEditor Win64 Development -Project=“D:\Game Dev\UE5\TFSovereign\TFSovereign.uproject” -WaitMutex -FromMsBuild” exited with code 6.
1>Done building project “TFSovereign.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========