Basic Shooting functionality fixed
Shooting now shoots a ray out and detects what object is being hit
This commit is contained in:
parent
c0cc7c4782
commit
5743e885e0
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
@ -7,7 +7,7 @@
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "BountyClass.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCompletedFirstCheckpoint)
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCompletedFirstCheckpoint);
|
||||
|
||||
UCLASS()
|
||||
class ENDLESSVENDETTA_API ABountyClass : public AActor
|
||||
|
@ -89,6 +89,7 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
||||
|
||||
//Weapon Shooting
|
||||
EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::TapFireCaller);
|
||||
EnhancedInputComponent->BindAction(HoldShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::TapFireCaller);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,11 +147,9 @@ void AEndlessVendettaCharacter::EquipPrimary()
|
||||
|
||||
if (IsValid(SecondaryWeapon)) EquipSecondary();
|
||||
|
||||
// Marcel I respect you, like you and what not, please for the love of god don't touch these two guard clauses
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;/////////////////////////
|
||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;///////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||
|
||||
|
||||
FActorSpawnParameters spawnParams;
|
||||
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
@ -164,53 +163,23 @@ void AEndlessVendettaCharacter::EquipPrimary()
|
||||
//We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor
|
||||
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
|
||||
|
||||
//If primary weapon is not there but secondary weapon is it will call equipSecondary.
|
||||
//EquipSecondary checks and sees that secondary is there so it will call to destroy itself
|
||||
//Code goes back and sees primary weapon is not there anymore and spawns it in.
|
||||
//Same thing for the EquipSecondary()
|
||||
|
||||
|
||||
// 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);
|
||||
// //Creating a new actor object called PrimaryWeapon that is based off primaryweaponClass
|
||||
// AActor* PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
|
||||
// PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
|
||||
// //Changing PrimaryWeaponActor to ABaseWeaponClass type instead of actor and storing it into PrimaryWeapon which is a ABaseClass Object
|
||||
// //We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor
|
||||
// PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
|
||||
//
|
||||
// }
|
||||
// else if (IsValid(PrimaryWeapon))
|
||||
// {
|
||||
// PrimaryWeapon->Destroy();
|
||||
// bHasRifle = false;
|
||||
// }
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::EquipSecondary()
|
||||
{
|
||||
if (IsValid(SecondaryWeapon))
|
||||
{
|
||||
SecondaryWeapon->Destroy();
|
||||
{
|
||||
SecondaryWeapon->Destroy();
|
||||
SecondaryWeapon = nullptr;
|
||||
bHasRifle = false;
|
||||
return;
|
||||
}
|
||||
bHasRifle = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsValid(PrimaryWeapon)) EquipPrimary();
|
||||
|
||||
// Marcel I respect you, like you and what not, please for the love of god don't touch these two guard clauses
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;/////////////////////////
|
||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;///////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
|
||||
if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
|
||||
|
||||
|
||||
FActorSpawnParameters spawnParams;
|
||||
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
@ -221,24 +190,6 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
||||
SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
|
||||
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
|
||||
|
||||
// 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;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -246,48 +197,12 @@ void AEndlessVendettaCharacter::EquipSecondary()
|
||||
void AEndlessVendettaCharacter::TapFireCaller()
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Tap Fire"));
|
||||
// if (IsValid(PrimaryWeapon) || IsValid(SecondaryWeapon))
|
||||
// {
|
||||
// PrimaryWeaponClass.GetDefaultObject()->TapFire();
|
||||
// }
|
||||
if (IsValid(PrimaryWeapon) || IsValid(SecondaryWeapon))
|
||||
{
|
||||
PrimaryWeapon->TapFire();
|
||||
}
|
||||
}
|
||||
|
||||
//POTENTIAL PICKUP SYSTEM NEEDS CHANGING BUT YES
|
||||
|
||||
//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"));
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
|
||||
|
@ -103,7 +103,6 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
void TapFireCaller();
|
||||
|
||||
|
||||
protected:
|
||||
/** Called for movement input */
|
||||
void Move(const FInputActionValue& Value);
|
||||
@ -119,9 +118,6 @@ protected:
|
||||
|
||||
void EquipSecondary();
|
||||
|
||||
//Called from Player BluePrints
|
||||
//UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||
//void WeaponPickUpSystem(AActor* PickedUpWeapon);
|
||||
|
||||
protected:
|
||||
// APawn interface
|
||||
@ -134,5 +130,6 @@ public:
|
||||
/** Returns FirstPersonCameraComponent subobject **/
|
||||
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -22,21 +22,13 @@ void ABaseWeaponClass::BeginPlay()
|
||||
// Attempt to find the player character
|
||||
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
|
||||
player = Cast<AEndlessVendettaCharacter>(PlayerController->GetCharacter());
|
||||
if (PlayerController)
|
||||
|
||||
for (UActorComponent* actorComp : player->GetComponentsByTag(UArrowComponent::StaticClass(), FName("GunStart")))
|
||||
{
|
||||
if (player)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("BeginPlay: Player found."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("BeginPlay: Player not found."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("BeginPlay: Player controller not found."));
|
||||
GunStartArrow = Cast<UArrowComponent>(actorComp);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
@ -47,20 +39,23 @@ void ABaseWeaponClass::Tick(float DeltaTime)
|
||||
|
||||
void ABaseWeaponClass::TapFire()
|
||||
{
|
||||
FTimerHandle timerHandle;
|
||||
FHitResult outHit;
|
||||
FVector traceStart;
|
||||
FVector traceEnd;
|
||||
traceStart = player->GetActorLocation();
|
||||
traceEnd = traceStart + (player->GetActorForwardVector() * 50);
|
||||
UE_LOG(LogTemp, Display, TEXT("World: %s"), *GetWorld()->GetName());
|
||||
traceStart = GunStartArrow->GetComponentLocation();
|
||||
traceEnd = traceStart + (player->GetActorForwardVector() * BulletDistance);
|
||||
FCollisionQueryParams collisionParams;
|
||||
collisionParams.AddIgnoredActor(player);
|
||||
collisionParams.AddIgnoredActor(this);
|
||||
GetWorldTimerManager().SetTimer(timerHandle, 1 / FireRate, false, 1.0f);
|
||||
GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams);
|
||||
|
||||
//Debug line to see where the trace hit
|
||||
DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, true);
|
||||
DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, true, 500.0f, 0U, 5.f);
|
||||
if (outHit.bBlockingHit)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Hit something"));
|
||||
UE_LOG(LogTemp, Display, TEXT("hit item: %s"), *outHit.GetActor()->GetName());
|
||||
|
||||
}
|
||||
UE_LOG(LogTemp, Display, TEXT("BOOMBOOMBIMBAMBIM"));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "WeaponItemClass.h"
|
||||
#include "Components/ArrowComponent.h"
|
||||
#include "BaseWeaponClass.generated.h"
|
||||
|
||||
class AEndlessVendettaCharacter;
|
||||
@ -47,7 +48,12 @@ public:
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
ACharacter* player;
|
||||
|
||||
private:
|
||||
|
||||
UArrowComponent* GunStartArrow;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float BulletDistance;
|
||||
|
||||
|
||||
//Add HoldFire functionality after pistol is complete for holding fire for pistol and make it start spraying innacuratly.
|
||||
|
Loading…
Reference in New Issue
Block a user