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 "Camera/CameraComponent.h"
|
||||
#include "Weapon/LMWeaponManager.h"
|
||||
|
||||
ALMPlayer::ALMPlayer()
|
||||
{
|
||||
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->SetupAttachment(GetMesh());
|
||||
|
||||
WeaponManager->SetWeaponMeshComponent(WeaponSkeletalMeshComponent);
|
||||
WeaponSkeletalMeshComponent->SetupAttachment(Camera);
|
||||
}
|
||||
|
||||
void ALMPlayer::BeginPlay()
|
||||
@ -22,6 +24,19 @@ void ALMPlayer::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)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
@ -22,10 +22,14 @@ void ULMWeaponManager::BeginPlay()
|
||||
ULMWeapon* Instance = NewObject<ULMWeapon>(this, Weapon);
|
||||
Weapons.Add(Instance);
|
||||
|
||||
// TODO
|
||||
// Instance->Initialize();
|
||||
Instance->Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh)
|
||||
{
|
||||
SetWeaponMeshComponent(Mesh);
|
||||
|
||||
if (!Weapons.IsEmpty())
|
||||
{
|
||||
@ -69,6 +73,8 @@ void ULMWeaponManager::Reload()
|
||||
|
||||
void ULMWeaponManager::SetWeapon(int Index)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Test"))
|
||||
|
||||
if (Index < 0 || Index >= Weapons.Num())
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index");
|
||||
@ -79,8 +85,9 @@ void ULMWeaponManager::SetWeapon(int Index)
|
||||
|
||||
if (WeaponMeshComponent)
|
||||
{
|
||||
// TODO
|
||||
// WeaponMeshComponent->SetSkeletalMesh()
|
||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Has Mesh");
|
||||
|
||||
WeaponMeshComponent->SetSkeletalMeshAsset(GetCurrentWeapon()->WeaponDataStructure.MeshWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "GameFramework/Character.h"
|
||||
#include "LMPlayer.generated.h"
|
||||
|
||||
class UCameraComponent;
|
||||
class ULMWeaponManager;
|
||||
|
||||
UCLASS()
|
||||
@ -25,10 +26,16 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
ULMWeaponManager* GetWeaponManager() { return WeaponManager; }
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetWeaponManager(ULMWeaponManager* Manager);
|
||||
|
||||
private:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<ULMWeaponManager> WeaponManager;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||
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
|
||||
|
||||
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)
|
||||
//enum AmmoType; //Type of ammo, which ammo this weapon is using
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void Reload();
|
||||
|
||||
void Initialize(USkeletalMeshComponent* Mesh);
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
|
Reference in New Issue
Block a user