Added New AR Test & Started working on switching system

This commit is contained in:
MH261677 2023-10-19 16:44:35 +01:00
parent feeb0f36d6
commit 6c1c5ca12e
7 changed files with 41 additions and 10 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fb7eb23a18c0ad9f5cf37ae72d45bac1d1b1d90fac9281cfa3e3233b9b6a3d44
size 42950
oid sha256:dfeced37123c7e12907f8c5c3882aa970013d96167d07df1d71a464e2f91fd0d
size 42429

View File

@ -84,7 +84,6 @@ void AEndlessVendettaCharacter::WeaponPickUpSystem()
if (!GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_Camera, QueryParams)) return;
AActor* HitActor = OutHit.GetActor();
UE_LOG(LogTemp, Warning, TEXT("Hit actor: %s"), *HitActor->GetName());
IInteractionInterface* InteractableActor = Cast<IInteractionInterface>(HitActor);
if (InteractableActor) InteractableActor->InteractPrompt();
}
@ -144,7 +143,11 @@ void AEndlessVendettaCharacter::Interact()
AActor* HitActor = OutHit.GetActor();
UE_LOG(LogTemp, Warning, TEXT("Hit actor: %s"), *HitActor->GetName());
IInteractionInterface* InteractableActor = Cast<IInteractionInterface>(HitActor);
if (InteractableActor) InteractableActor->Interact();
if (InteractableActor)
{
InteractableActor->Interact();
WeaponSwitcher(OutHit);
}
}
@ -271,6 +274,13 @@ void AEndlessVendettaCharacter::EquipSecondary()
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
}
void AEndlessVendettaCharacter::WeaponSwitcher(FHitResult Outhit)
{
if (IsValid(PrimaryWeapon)) PrimaryWeapon->Destroy();
PrimaryWeapon = Cast<ABaseWeaponClass>(Outhit.GetActor());
Outhit.GetActor()->Destroy();
}
//Calls the fire function in the baseWeaponClass
void AEndlessVendettaCharacter::FireCaller()
{

View File

@ -148,9 +148,6 @@ protected:
void ToggleRecon();
void ToggleCombat();
void EquipPrimary();
void EquipSecondary();
UPROPERTY(EditDefaultsOnly, Category = "Interaction")
float InteractionRange = 250;
void Interact();
@ -175,4 +172,9 @@ public:
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
void WeaponPickUpSystem();
void EquipPrimary();
void EquipSecondary();
void WeaponSwitcher(FHitResult Outhit);
};

View File

@ -232,15 +232,29 @@ void ABaseWeaponClass::WeaponReload()
void ABaseWeaponClass::Interact()
{
if(!IsValid(this)) return;
GLog->Log("Interact Called");
}
void ABaseWeaponClass::InteractPrompt()
{
WeaponStatsPopUp();
UE_LOG(LogTemp, Warning, TEXT("InteractPrompt setup"))
}
// void ABaseWeaponClass::GetOutHit(FHitResult OutHit)
// {
// if(IsValid(this))
// {
// endlessVendettaChar->PrimaryWeapon->Destroy();
// }
// if (OutHit.GetActor()->ActorHasTag(FName("AssaultRifle")))
// {
// endlessVendettaChar->EquipPrimary();
// }
// //HitActor = Cast<ABaseWeaponClass>(endlessVendettaChar->PrimaryWeaponClass);
// //endlessVendettaChar->PrimaryWeapon = Cast<ABaseWeaponClass>(HitActor);
// }

View File

@ -168,6 +168,8 @@ public:
UFUNCTION(BlueprintImplementableEvent)
void WeaponStatsPopUp();
//void GetOutHit(FHitResult OutHit);
protected:
UArrowComponent* GunStartArrow;
bool bStopShooting = false;