Added Pickup Functionality and working on spawning to hand
This commit is contained in:
parent
09b22ff33d
commit
9a75262e66
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:2d5de8f4e27f1e085417782dd7729fc662c3ab813afabba992a0bfe6ad51573c
|
oid sha256:92f8bdd8d4e8196894411a8141429f15316d83e076b0163070ee174bd3eb4ac7
|
||||||
size 35545
|
size 32087
|
||||||
|
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f562f592d0a4fc6f34c7deb5c861593a1b7282f786b19b3789fbac2bee01c7a1
|
oid sha256:60c71c86a00bef84374641ca7fed67e2338916dba788e69d643a8477add71d97
|
||||||
size 29063
|
size 29026
|
||||||
|
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_EquipPrimaryWeapon.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_EquipPrimaryWeapon.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_EquipSecondaryWeapon.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_EquipSecondaryWeapon.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:d0c07e01e5199aaa3d4e7fb5dc36733918e91aa93620cbef070e2472021315d4
|
|
||||||
size 1672
|
|
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:7d38ac187045f18e01436a5d90333878b3490d25037c84c712f943cb34f785bb
|
oid sha256:ffa41b9939bbfe39ea2480464028578938aa1a8c0acc1edeac030ade6d1d9d76
|
||||||
size 14484
|
size 14001
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:df93071fd48bde5bf300bdb99470e05451e488b38627fbf6b22212b3c03e0fd3
|
oid sha256:abfeb59ea7bea538e1b873a97345a0336c40b7c353d167ddd1a4fac4a16dcad6
|
||||||
size 5061
|
size 5061
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:4c7be8ced7b103ba47409aefeea3621d8602fcd366160651c53447a7c2f866e4
|
||||||
|
size 5097
|
@ -71,7 +71,53 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
|||||||
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
||||||
|
|
||||||
//Weapon Switching
|
//Weapon Switching
|
||||||
EnhancedInputComponent->BindAction(WeaponEquipAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::WeaponEquip);
|
EnhancedInputComponent->BindAction(EquipPrimaryWeapon, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::EquipPrimary);
|
||||||
|
EnhancedInputComponent->BindAction(EquipSecondaryWeapon, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::EquipSecondary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::EquipPrimary()
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Primary equipped"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::EquipSecondary()
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Secondary equipped"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called from Player BluePrints
|
||||||
|
void AEndlessVendettaCharacter::WeaponPickUpSystem(AActor* PickedUpWeapon)
|
||||||
|
{
|
||||||
|
ABaseWeaponClass* WeaponInWorld = Cast<ABaseWeaponClass>(PickedUpWeapon);
|
||||||
|
if(WeaponInWorld->IsA(ABaseWeaponClass::StaticClass()))
|
||||||
|
{
|
||||||
|
if(PrimaryWeapon)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Primary Weapon Picked up"));
|
||||||
|
bHasRifle = true;
|
||||||
|
FVector loc = GetActorLocation() + FVector(-50, 0, 0);
|
||||||
|
FRotator rot = GetActorRotation();
|
||||||
|
FActorSpawnParameters spawnParams;
|
||||||
|
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||||
|
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
|
||||||
|
//WeaponInWorld = Cast<ABaseWeaponClass>(GetWorld()->SpawnActor<AActor>(PrimaryWeapon, loc, rot, spawnParams));
|
||||||
|
WeaponInWorld->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
|
||||||
|
WeaponInWorld->Destroy();
|
||||||
|
|
||||||
|
//for some reason the spawning of the weapon is broken to the players hand so need to fix this.
|
||||||
|
|
||||||
|
// potentially add a varibable to check if its a secondary or priamry weapon being picked up
|
||||||
|
// add this in the baseweaponclass variable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(WeaponInWorld->IsA(ABaseWeaponClass::StaticClass()))
|
||||||
|
{
|
||||||
|
if(SecondaryWeapon)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Secondary Weapon Picked up"));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +148,6 @@ void AEndlessVendettaCharacter::Look(const FInputActionValue& Value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::WeaponEquip()
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Display, TEXT("EQUIPPING WEAPONS"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::SetHasRifle(bool bNewHasRifle)
|
void AEndlessVendettaCharacter::SetHasRifle(bool bNewHasRifle)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "BaseWeaponClass.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
#include "InputActionValue.h"
|
#include "InputActionValue.h"
|
||||||
#include "EndlessVendettaCharacter.generated.h"
|
#include "EndlessVendettaCharacter.generated.h"
|
||||||
@ -42,7 +43,10 @@ class AEndlessVendettaCharacter : public ACharacter
|
|||||||
|
|
||||||
/** Weapon Equip Action */
|
/** Weapon Equip Action */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
||||||
class UInputAction* WeaponEquipAction;
|
class UInputAction* EquipPrimaryWeapon;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
||||||
|
class UInputAction* EquipSecondaryWeapon;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -69,15 +73,27 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = Weapon)
|
UFUNCTION(BlueprintCallable, Category = Weapon)
|
||||||
bool GetHasRifle();
|
bool GetHasRifle();
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Weapons")
|
||||||
|
TSubclassOf<ABaseWeaponClass> PrimaryWeapon;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Weapons")
|
||||||
|
TSubclassOf<ABaseWeaponClass> SecondaryWeapon;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Called for movement input */
|
/** Called for movement input */
|
||||||
void Move(const FInputActionValue& Value);
|
void Move(const FInputActionValue& Value);
|
||||||
|
|
||||||
/** Called for looking input */
|
/** Called for looking input */
|
||||||
void Look(const FInputActionValue& Value);
|
void Look(const FInputActionValue& Value);
|
||||||
|
|
||||||
|
void EquipPrimary();
|
||||||
|
|
||||||
|
void EquipSecondary();
|
||||||
|
|
||||||
void WeaponEquip();
|
//Called from Player BluePrints
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
|
void WeaponPickUpSystem(AActor* PickedUpWeapon);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// APawn interface
|
// APawn interface
|
||||||
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
|
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
|
||||||
@ -88,10 +104,6 @@ public:
|
|||||||
USkeletalMeshComponent* GetMesh1P() const { return Mesh1P; }
|
USkeletalMeshComponent* GetMesh1P() const { return Mesh1P; }
|
||||||
/** Returns FirstPersonCameraComponent subobject **/
|
/** Returns FirstPersonCameraComponent subobject **/
|
||||||
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
||||||
|
|
||||||
private:
|
|
||||||
UWeaponInventory* WeaponInventory;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "WeaponInventory.h"
|
|
||||||
|
|
||||||
#include "WeaponItemClass.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Sets default values for this component's properties
|
|
||||||
UWeaponInventory::UWeaponInventory()
|
|
||||||
{
|
|
||||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
|
||||||
// off to improve performance if you don't need them.
|
|
||||||
PrimaryComponentTick.bCanEverTick = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Called when the game starts
|
|
||||||
void UWeaponInventory::BeginPlay()
|
|
||||||
{
|
|
||||||
Super::BeginPlay();
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Called every frame
|
|
||||||
void UWeaponInventory::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
|
||||||
{
|
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
//Called from blueprints from the player
|
|
||||||
void UWeaponInventory::WeaponPickup(AActor* WeaponPickedUp)
|
|
||||||
{
|
|
||||||
AWeaponItemClass* WeaponItemClass = Cast<AWeaponItemClass>(WeaponPickedUp);
|
|
||||||
WeaponsArray.Add(WeaponItemClass);
|
|
||||||
WeaponPickedUp->Destroy();
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "Components/ActorComponent.h"
|
|
||||||
#include "WeaponInventory.generated.h"
|
|
||||||
|
|
||||||
|
|
||||||
class AWeaponItemClass;
|
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
|
||||||
class ENDLESSVENDETTA_API UWeaponInventory : public UActorComponent
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Sets default values for this component's properties
|
|
||||||
UWeaponInventory();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Called when the game starts
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, Category = "Weapon System")
|
|
||||||
TArray<AWeaponItemClass*> WeaponsArray;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Called every frame
|
|
||||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
|
||||||
|
|
||||||
//Using a getter to get the protected weaponsArray
|
|
||||||
UFUNCTION()
|
|
||||||
TArray<AWeaponItemClass*> GetWeaponArray() const { return WeaponsArray; }
|
|
||||||
|
|
||||||
//Using a Setter to set the protected weapons array to the getter
|
|
||||||
UFUNCTION()
|
|
||||||
void SetArray(const TArray<AWeaponItemClass*> weaponArray) { WeaponsArray = weaponArray; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
//Called from blueprints from the player
|
|
||||||
UFUNCTION(BlueprintCallable)
|
|
||||||
void WeaponPickup(AActor* WeaponPickedUp);
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user