Added Binding for firing and reloading
This commit is contained in:
parent
a107f650c8
commit
f39f90b411
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Player/Input/IA_Reload.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Player/Input/IA_Reload.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Player/Input/IMC_Default.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/Input/IMC_Default.uasset
(Stored with Git LFS)
Binary file not shown.
@ -6,6 +6,7 @@
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Player/LMPlayer.h"
|
||||
#include "Weapon/LMWeaponManager.h"
|
||||
|
||||
void ALMPlayerController::BeginPlay()
|
||||
{
|
||||
@ -22,6 +23,8 @@ void ALMPlayerController::SetupInputComponent()
|
||||
Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move);
|
||||
Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Jump);
|
||||
Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look);
|
||||
Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire);
|
||||
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
|
||||
}
|
||||
|
||||
void ALMPlayerController::Move(const FInputActionValue& InputValue)
|
||||
@ -41,4 +44,14 @@ void ALMPlayerController::Look(const FInputActionValue& InputValue)
|
||||
const FVector2d VectorDirection = InputValue.Get<FVector2d>();
|
||||
AddYawInput(VectorDirection.X);
|
||||
AddPitchInput(VectorDirection.Y);
|
||||
}
|
||||
}
|
||||
|
||||
void ALMPlayerController::Fire(const FInputActionValue& InputValue)
|
||||
{
|
||||
LegumixPlayer->GetWeaponManager()->Fire();
|
||||
}
|
||||
|
||||
void ALMPlayerController::Reload(const FInputActionValue& InputValue)
|
||||
{
|
||||
LegumixPlayer->GetWeaponManager()->Reload();
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ void ULMWeaponManager::BeginPlay()
|
||||
{
|
||||
ULMWeapon* Instance = NewObject<ULMWeapon>(this, Weapon);
|
||||
Weapons.Add(Instance);
|
||||
|
||||
// TODO
|
||||
// Instance->Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +33,39 @@ void ULMWeaponManager::BeginPlay()
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount)
|
||||
{
|
||||
FString Debug = FString::Printf(TEXT("Adding %i ammo of type %i"), AmmoCount, AmmoType);
|
||||
GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug);
|
||||
|
||||
for (const auto Weapon : Weapons)
|
||||
{
|
||||
// TODO : match weapon ammo type
|
||||
if (!Weapon)
|
||||
continue;
|
||||
|
||||
// TODO
|
||||
// Weapon.AddAmmo(AmmoCount);
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Fire()
|
||||
{
|
||||
// ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
|
||||
GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire");
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Reload()
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading");
|
||||
|
||||
|
||||
// ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
// TODO
|
||||
// Weapon->Reload();
|
||||
}
|
||||
|
||||
void ULMWeaponManager::SetWeapon(int Index)
|
||||
{
|
||||
|
@ -15,14 +15,15 @@ class LEGUMEMIX_API ALMPlayer : public ACharacter
|
||||
|
||||
public:
|
||||
ALMPlayer();
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
UFUNCTION(BlueprintCallable)
|
||||
ULMWeaponManager* GetWeaponManager() { return WeaponManager; }
|
||||
|
||||
private:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||
|
@ -36,6 +36,12 @@ private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> JumpAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> FireAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> ReloadAction;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<ALMPlayer> LegumixPlayer;
|
||||
|
||||
@ -43,4 +49,6 @@ private:
|
||||
void Move(const FInputActionValue& InputValue);
|
||||
void Jump(const FInputActionValue& InputValue);
|
||||
void Look(const FInputActionValue& InputValue);
|
||||
void Fire(const FInputActionValue& InputValue);
|
||||
void Reload(const FInputActionValue& InputValue);
|
||||
};
|
||||
|
@ -29,6 +29,15 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void SetWeapon(int Index);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void AddAmmoType(uint8 AmmoType, int AmmoCount);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void Fire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void Reload();
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
|
Reference in New Issue
Block a user