Added player weapon display
This commit is contained in:
parent
6da5f75089
commit
99707d1b73
BIN
Content/Legumix/Player/BP_Player.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_Player.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Weapon/BP_WeaponManager.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Weapon/BP_WeaponManager.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Weapon/DT_WeaponData.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Weapon/DT_WeaponData.uasset
(Stored with Git LFS)
Binary file not shown.
@ -3,18 +3,20 @@
|
|||||||
|
|
||||||
#include "Player/LMPlayer.h"
|
#include "Player/LMPlayer.h"
|
||||||
|
|
||||||
|
#include "Camera/CameraComponent.h"
|
||||||
#include "Weapon/LMWeaponManager.h"
|
#include "Weapon/LMWeaponManager.h"
|
||||||
|
|
||||||
ALMPlayer::ALMPlayer()
|
ALMPlayer::ALMPlayer()
|
||||||
{
|
{
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
|
||||||
WeaponManager = CreateDefaultSubobject<ULMWeaponManager>(TEXT("Weapon Manager"));
|
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
|
||||||
|
Camera->SetupAttachment(RootComponent);
|
||||||
|
Camera->bUsePawnControlRotation = true;
|
||||||
|
Camera->SetRelativeLocation(FVector(20, 0, 90));
|
||||||
|
|
||||||
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Weapon Mesh"));
|
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Weapon Mesh"));
|
||||||
WeaponSkeletalMeshComponent->SetupAttachment(GetMesh());
|
WeaponSkeletalMeshComponent->SetupAttachment(Camera);
|
||||||
|
|
||||||
WeaponManager->SetWeaponMeshComponent(WeaponSkeletalMeshComponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALMPlayer::BeginPlay()
|
void ALMPlayer::BeginPlay()
|
||||||
@ -22,6 +24,19 @@ void ALMPlayer::BeginPlay()
|
|||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Set weapon manager"))
|
||||||
|
if (!Manager)
|
||||||
|
{
|
||||||
|
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.f, FColor::Red, TEXT("No Weapon Manager was given to the player !"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WeaponManager = Manager;
|
||||||
|
WeaponManager->Initialize(WeaponSkeletalMeshComponent);
|
||||||
|
}
|
||||||
|
|
||||||
void ALMPlayer::Tick(float DeltaTime)
|
void ALMPlayer::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
@ -21,12 +21,16 @@ void ULMWeaponManager::BeginPlay()
|
|||||||
{
|
{
|
||||||
ULMWeapon* Instance = NewObject<ULMWeapon>(this, Weapon);
|
ULMWeapon* Instance = NewObject<ULMWeapon>(this, Weapon);
|
||||||
Weapons.Add(Instance);
|
Weapons.Add(Instance);
|
||||||
|
|
||||||
// TODO
|
Instance->Initialize();
|
||||||
// Instance->Initialize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh)
|
||||||
|
{
|
||||||
|
SetWeaponMeshComponent(Mesh);
|
||||||
|
|
||||||
if (!Weapons.IsEmpty())
|
if (!Weapons.IsEmpty())
|
||||||
{
|
{
|
||||||
SetWeapon(CurrentWeaponIndex);
|
SetWeapon(CurrentWeaponIndex);
|
||||||
@ -69,6 +73,8 @@ void ULMWeaponManager::Reload()
|
|||||||
|
|
||||||
void ULMWeaponManager::SetWeapon(int Index)
|
void ULMWeaponManager::SetWeapon(int Index)
|
||||||
{
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Test"))
|
||||||
|
|
||||||
if (Index < 0 || Index >= Weapons.Num())
|
if (Index < 0 || Index >= Weapons.Num())
|
||||||
{
|
{
|
||||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index");
|
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index");
|
||||||
@ -79,8 +85,9 @@ void ULMWeaponManager::SetWeapon(int Index)
|
|||||||
|
|
||||||
if (WeaponMeshComponent)
|
if (WeaponMeshComponent)
|
||||||
{
|
{
|
||||||
// TODO
|
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Has Mesh");
|
||||||
// WeaponMeshComponent->SetSkeletalMesh()
|
|
||||||
|
WeaponMeshComponent->SetSkeletalMeshAsset(GetCurrentWeapon()->WeaponDataStructure.MeshWeapon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
#include "LMPlayer.generated.h"
|
#include "LMPlayer.generated.h"
|
||||||
|
|
||||||
|
class UCameraComponent;
|
||||||
class ULMWeaponManager;
|
class ULMWeaponManager;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
@ -25,10 +26,16 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
ULMWeaponManager* GetWeaponManager() { return WeaponManager; }
|
ULMWeaponManager* GetWeaponManager() { return WeaponManager; }
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void SetWeaponManager(ULMWeaponManager* Manager);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||||
TObjectPtr<ULMWeaponManager> WeaponManager;
|
TObjectPtr<ULMWeaponManager> WeaponManager;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||||
TObjectPtr<USkeletalMeshComponent> WeaponSkeletalMeshComponent;
|
TObjectPtr<USkeletalMeshComponent> WeaponSkeletalMeshComponent;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||||
|
TObjectPtr<UCameraComponent> Camera;
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@ struct FLMWeaponDataStructure : public FTableRowBase
|
|||||||
int MaxClipAmmo; // Max ammo in clip
|
int MaxClipAmmo; // Max ammo in clip
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
TObjectPtr<UStaticMesh> MeshWeapon; //Mesh of the weapon display in the scene
|
TObjectPtr<USkeletalMesh> MeshWeapon; //Mesh of the weapon display in the scene
|
||||||
|
|
||||||
//UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
//UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
//enum AmmoType; //Type of ammo, which ammo this weapon is using
|
//enum AmmoType; //Type of ammo, which ammo this weapon is using
|
||||||
|
@ -37,6 +37,8 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
|
void Initialize(USkeletalMeshComponent* Mesh);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
Reference in New Issue
Block a user