Added Simple Gun Swapping and un-equip

This commit is contained in:
MARCEL HARA 2023-09-28 11:42:16 +01:00
parent 9a75262e66
commit 1432b479b2
8 changed files with 64 additions and 23 deletions

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:92f8bdd8d4e8196894411a8141429f15316d83e076b0163070ee174bd3eb4ac7
size 32087
oid sha256:46657eb5de2de0259508b2ff818d484f06f895c13f8bb3d04c6fc34ea61659a1
size 23694

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c4714323c517973cefc36046bc8310e35417fac27e8b323667e4a46c5c09ba5f
size 14803
oid sha256:e5a9006c075f35f1cab65fb02d8034543f6b54e6087f7352477f45abf6640e43
size 14831

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:abfeb59ea7bea538e1b873a97345a0336c40b7c353d167ddd1a4fac4a16dcad6
size 5061

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4c7be8ced7b103ba47409aefeea3621d8602fcd366160651c53447a7c2f866e4
size 5097

View File

@ -78,16 +78,54 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
void AEndlessVendettaCharacter::EquipPrimary()
{
UE_LOG(LogTemp, Display, TEXT("Primary equipped"));
if (!IsValid(PrimaryWeapon))
{
if (IsValid(SecondaryWeapon)) EquipSecondary();
UE_LOG(LogTemp, Display, TEXT("Primary equipped"));
bHasRifle = true;
FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
AActor* PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
}
else if (IsValid(PrimaryWeapon))
{
PrimaryWeapon->Destroy();
bHasRifle = false;
}
}
void AEndlessVendettaCharacter::EquipSecondary()
{
UE_LOG(LogTemp, Display, TEXT("Secondary equipped"));
if (!IsValid(SecondaryWeapon))
{
if (IsValid(PrimaryWeapon)) EquipPrimary();
UE_LOG(LogTemp, Display, TEXT("Secondary equipped"));
bHasRifle = true;
FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
AActor* SecondaryWeaponActor = GetWorld()->SpawnActor<AActor>(SecondaryWeaponClass, spawnParams);
SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
}
else if (IsValid(SecondaryWeapon))
{
SecondaryWeapon->Destroy();
bHasRifle = false;
}
}
//POTENTIAL PICKUP SYSTEM NEEDS CHANGING BUT YES
//Called from Player BluePrints
void AEndlessVendettaCharacter::WeaponPickUpSystem(AActor* PickedUpWeapon)
/*void AEndlessVendettaCharacter::WeaponPickUpSystem(AActor* PickedUpWeapon)
{
ABaseWeaponClass* WeaponInWorld = Cast<ABaseWeaponClass>(PickedUpWeapon);
if(WeaponInWorld->IsA(ABaseWeaponClass::StaticClass()))
@ -119,7 +157,7 @@ void AEndlessVendettaCharacter::WeaponPickUpSystem(AActor* PickedUpWeapon)
}
}
}
}*/
void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)

View File

@ -6,6 +6,7 @@
#include "BaseWeaponClass.h"
#include "GameFramework/Character.h"
#include "InputActionValue.h"
#include "Components/ArrowComponent.h"
#include "EndlessVendettaCharacter.generated.h"
class UWeaponInventory;
@ -74,10 +75,15 @@ public:
bool GetHasRifle();
UPROPERTY(EditAnywhere, Category = "Weapons")
TSubclassOf<ABaseWeaponClass> PrimaryWeapon;
TSubclassOf<ABaseWeaponClass> PrimaryWeaponClass;
UPROPERTY(EditAnywhere, Category = "Weapons")
TSubclassOf<ABaseWeaponClass> SecondaryWeapon;
TSubclassOf<ABaseWeaponClass> SecondaryWeaponClass;
ABaseWeaponClass* PrimaryWeapon;
ABaseWeaponClass* SecondaryWeapon;
protected:
/** Called for movement input */
@ -91,8 +97,8 @@ protected:
void EquipSecondary();
//Called from Player BluePrints
UFUNCTION(BlueprintCallable, Category = "Weapons")
void WeaponPickUpSystem(AActor* PickedUpWeapon);
//UFUNCTION(BlueprintCallable, Category = "Weapons")
//void WeaponPickUpSystem(AActor* PickedUpWeapon);
protected:
// APawn interface