Compare commits
No commits in common. "b68fd35f4d5966b92290606e6b0242fdd04141ec" and "633c66ff6f952b74a6587e277374c44f1816c0f0" have entirely different histories.
b68fd35f4d
...
633c66ff6f
BIN
Content/Weapons/Pistol/Pistol.uasset
(Stored with Git LFS)
BIN
Content/Weapons/Pistol/Pistol.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Weapons/Shotgun/Shotgun.uasset
(Stored with Git LFS)
BIN
Content/Weapons/Shotgun/Shotgun.uasset
(Stored with Git LFS)
Binary file not shown.
@ -4,7 +4,6 @@
|
|||||||
#include "EnemyAIController.h"
|
#include "EnemyAIController.h"
|
||||||
#include "EnemyHealthComponent.h"
|
#include "EnemyHealthComponent.h"
|
||||||
#include "InteractableComponent.h"
|
#include "InteractableComponent.h"
|
||||||
#include "NiagaraFunctionLibrary.h"
|
|
||||||
#include "BehaviorTree/BehaviorTree.h"
|
#include "BehaviorTree/BehaviorTree.h"
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
#include "BehaviorTree/BlackboardData.h"
|
#include "BehaviorTree/BlackboardData.h"
|
||||||
@ -34,9 +33,8 @@ void AEnemyCharacter::OnFire()
|
|||||||
CurrentWeapon->SetCurrentWeaponStatus(Firing);
|
CurrentWeapon->SetCurrentWeaponStatus(Firing);
|
||||||
|
|
||||||
TArray<FHitResult> Hits = TArray<FHitResult>();
|
TArray<FHitResult> Hits = TArray<FHitResult>();
|
||||||
FVector direction = FVector::ZeroVector;
|
CalculateHits(&Hits);
|
||||||
CalculateHits(&Hits, &direction);
|
ProcessHits(Hits);
|
||||||
ProcessHits(Hits, direction);
|
|
||||||
|
|
||||||
CurrentWeapon->PlayFireSoundAtLocation(GetActorLocation());
|
CurrentWeapon->PlayFireSoundAtLocation(GetActorLocation());
|
||||||
|
|
||||||
@ -70,7 +68,7 @@ void AEnemyCharacter::PlayOnFireAnimations()
|
|||||||
Super::PlayOnFireAnimations();
|
Super::PlayOnFireAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir)
|
void AEnemyCharacter::CalculateHits(TArray<FHitResult>* hits)
|
||||||
{
|
{
|
||||||
// Set up randomness
|
// Set up randomness
|
||||||
const int32 RandomSeed = FMath::Rand();
|
const int32 RandomSeed = FMath::Rand();
|
||||||
@ -110,7 +108,7 @@ void AEnemyCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
|
void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
{
|
{
|
||||||
for (FHitResult Hit : hits)
|
for (FHitResult Hit : hits)
|
||||||
{
|
{
|
||||||
@ -119,19 +117,11 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
|
|||||||
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||||
|
|
||||||
// Spawn field actor
|
// Spawn field actor
|
||||||
if (CurrentWeapon->GetFieldSystemActor())
|
|
||||||
{
|
|
||||||
FTransform transform;
|
FTransform transform;
|
||||||
transform.SetLocation(Hit.ImpactPoint);
|
transform.SetLocation(Hit.ImpactPoint);
|
||||||
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform,
|
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform,
|
||||||
SpawnParameters);
|
SpawnParameters);
|
||||||
|
|
||||||
if (field)
|
|
||||||
{
|
|
||||||
field->Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Hit.GetActor())
|
if (Hit.GetActor())
|
||||||
{
|
{
|
||||||
if (auto interactableComponent = Hit.GetActor()->GetComponentByClass<UInteractableComponent>())
|
if (auto interactableComponent = Hit.GetActor()->GetComponentByClass<UInteractableComponent>())
|
||||||
@ -145,36 +135,6 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
|
|||||||
GetController(), this);
|
GetController(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto staticMeshComponent = Hit.GetActor()->GetComponentByClass<UStaticMeshComponent>();
|
|
||||||
|
|
||||||
if (staticMeshComponent && !staticMeshComponent->IsSimulatingPhysics() && CurrentWeapon->GetDecalActor())
|
|
||||||
{
|
|
||||||
FTransform transform;
|
|
||||||
transform.SetLocation(Hit.ImpactPoint);
|
|
||||||
|
|
||||||
auto decalActor = GetWorld()->SpawnActor<ADecalActor>(CurrentWeapon->GetDecalActor(), transform,
|
|
||||||
SpawnParameters);
|
|
||||||
auto rot = Hit.ImpactNormal.Rotation();
|
|
||||||
rot.Roll += 90.0f;
|
|
||||||
rot.Yaw += 180.0f;
|
|
||||||
decalActor->SetActorRotation(rot);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (staticMeshComponent && !staticMeshComponent->IsSimulatingPhysics() &&
|
|
||||||
CurrentWeapon->GetImpactParticleSystem())
|
|
||||||
{
|
|
||||||
FTransform transform;
|
|
||||||
transform.SetLocation(Hit.ImpactPoint);
|
|
||||||
|
|
||||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this,
|
|
||||||
CurrentWeapon->GetImpactParticleSystem(),
|
|
||||||
transform.GetLocation(),
|
|
||||||
dir.MirrorByVector(Hit.ImpactNormal).Rotation(),
|
|
||||||
FVector(1),
|
|
||||||
true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
virtual void PlayOnFireAnimations() override;
|
virtual void PlayOnFireAnimations() override;
|
||||||
|
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits, FVector* dir) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||||
|
|
||||||
virtual void ProcessHits(TArray<FHitResult> hits, FVector dir) override;
|
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnDamaged() override;
|
virtual void OnDamaged() override;
|
||||||
|
@ -11,7 +11,7 @@ public class Nakatomi : ModuleRules
|
|||||||
PublicDependencyModuleNames.AddRange(new[]
|
PublicDependencyModuleNames.AddRange(new[]
|
||||||
{
|
{
|
||||||
"Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "FieldSystemEngine",
|
"Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "FieldSystemEngine",
|
||||||
"GeometryCollectionEngine", "UMG", "AIModule", "GameplayTasks", "NavigationSystem", "Niagara"
|
"GeometryCollectionEngine", "UMG", "AIModule", "GameplayTasks", "NavigationSystem"
|
||||||
});
|
});
|
||||||
|
|
||||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||||
|
@ -257,11 +257,11 @@ bool ANakatomiCharacter::GetCrouched()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ANakatomiCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir)
|
void ANakatomiCharacter::CalculateHits(TArray<FHitResult>* hits)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ANakatomiCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
|
void ANakatomiCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,9 +116,9 @@ public:
|
|||||||
bool GetCrouched();
|
bool GetCrouched();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits, FVector* dir);
|
virtual void CalculateHits(TArray<FHitResult>* hits);
|
||||||
|
|
||||||
virtual void ProcessHits(TArray<FHitResult> hits, FVector dir);
|
virtual void ProcessHits(TArray<FHitResult> hits);
|
||||||
|
|
||||||
virtual void PlayOnFireAnimations();
|
virtual void PlayOnFireAnimations();
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "InteractableComponent.h"
|
#include "InteractableComponent.h"
|
||||||
#include "NakatomiCMC.h"
|
#include "NakatomiCMC.h"
|
||||||
#include "WeaponThrowable.h"
|
#include "WeaponThrowable.h"
|
||||||
#include "NiagaraFunctionLibrary.h"
|
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
|
|
||||||
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
||||||
@ -319,7 +318,7 @@ void APlayerCharacter::SetWalkingCallback(const FInputActionInstance& Instance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir)
|
void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
|
||||||
{
|
{
|
||||||
// Set up the collision query params, use the Weapon trace settings, Ignore the actor firing this trace
|
// Set up the collision query params, use the Weapon trace settings, Ignore the actor firing this trace
|
||||||
FCollisionQueryParams TraceParams(SCENE_QUERY_STAT(WeaponTrace), true, GetInstigator());
|
FCollisionQueryParams TraceParams(SCENE_QUERY_STAT(WeaponTrace), true, GetInstigator());
|
||||||
@ -350,7 +349,6 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir)
|
|||||||
TraceStart = GetRootComponent()->GetComponentLocation();
|
TraceStart = GetRootComponent()->GetComponentLocation();
|
||||||
FVector AimDir = CamHit.ImpactPoint - TraceStart;
|
FVector AimDir = CamHit.ImpactPoint - TraceStart;
|
||||||
AimDir.Normalize();
|
AimDir.Normalize();
|
||||||
*dir = AimDir;
|
|
||||||
TraceStart = TraceStart + AimDir * ((GetInstigator()->GetActorLocation() - TraceStart) | AimDir);
|
TraceStart = TraceStart + AimDir * ((GetInstigator()->GetActorLocation() - TraceStart) | AimDir);
|
||||||
|
|
||||||
// Calculate the hit results from the trace
|
// Calculate the hit results from the trace
|
||||||
@ -373,7 +371,7 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
|
void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
{
|
{
|
||||||
for (FHitResult Hit : hits)
|
for (FHitResult Hit : hits)
|
||||||
{
|
{
|
||||||
@ -439,13 +437,11 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
|
|||||||
FTransform transform;
|
FTransform transform;
|
||||||
transform.SetLocation(Hit.ImpactPoint);
|
transform.SetLocation(Hit.ImpactPoint);
|
||||||
|
|
||||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this,
|
UGameplayStatics::SpawnEmitterAtLocation(this,
|
||||||
CurrentWeapon->GetImpactParticleSystem(),
|
CurrentWeapon->GetImpactParticleSystem(),
|
||||||
transform.GetLocation(),
|
transform.GetLocation(),
|
||||||
dir.MirrorByVector(Hit.ImpactNormal).Rotation(),
|
FRotator::ZeroRotator,
|
||||||
FVector(1),
|
|
||||||
true);
|
true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,9 +643,8 @@ void APlayerCharacter::OnFire()
|
|||||||
CurrentWeapon->SetCurrentWeaponStatus(Firing);
|
CurrentWeapon->SetCurrentWeaponStatus(Firing);
|
||||||
|
|
||||||
TArray<FHitResult> Hits = TArray<FHitResult>();
|
TArray<FHitResult> Hits = TArray<FHitResult>();
|
||||||
FVector direction = FVector::ZeroVector;
|
CalculateHits(&Hits);
|
||||||
CalculateHits(&Hits, &direction);
|
ProcessHits(Hits);
|
||||||
ProcessHits(Hits, direction);
|
|
||||||
|
|
||||||
CurrentWeapon->DecrementAmmoCount(1);
|
CurrentWeapon->DecrementAmmoCount(1);
|
||||||
|
|
||||||
|
@ -243,9 +243,9 @@ public:
|
|||||||
void SetIsThrowing(bool bIsThrowing);
|
void SetIsThrowing(bool bIsThrowing);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits, FVector* dir) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||||
|
|
||||||
virtual void ProcessHits(TArray<FHitResult> hits, FVector dir) override;
|
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||||
|
|
||||||
virtual void PlayOnFireAnimations() override;
|
virtual void PlayOnFireAnimations() override;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ TSubclassOf<ADecalActor> AWeapon::GetDecalActor()
|
|||||||
return DecalActor;
|
return DecalActor;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNiagaraSystem* AWeapon::GetImpactParticleSystem()
|
UParticleSystem* AWeapon::GetImpactParticleSystem()
|
||||||
{
|
{
|
||||||
return ImpactParticleSystem;
|
return ImpactParticleSystem;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "NakatomiFieldSystemActor.h"
|
#include "NakatomiFieldSystemActor.h"
|
||||||
#include "WeaponProperties.h"
|
#include "WeaponProperties.h"
|
||||||
#include "WeaponThrowable.h"
|
#include "WeaponThrowable.h"
|
||||||
#include "NiagaraSystem.h"
|
|
||||||
#include "Weapon.generated.h"
|
#include "Weapon.generated.h"
|
||||||
|
|
||||||
class ANakatomiCharacter;
|
class ANakatomiCharacter;
|
||||||
@ -57,7 +56,7 @@ protected:
|
|||||||
TSubclassOf<class ADecalActor> DecalActor;
|
TSubclassOf<class ADecalActor> DecalActor;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
UNiagaraSystem* ImpactParticleSystem;
|
UParticleSystem* ImpactParticleSystem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
@ -106,5 +105,5 @@ public:
|
|||||||
|
|
||||||
TSubclassOf<class ADecalActor> GetDecalActor();
|
TSubclassOf<class ADecalActor> GetDecalActor();
|
||||||
|
|
||||||
UNiagaraSystem* GetImpactParticleSystem();
|
UParticleSystem* GetImpactParticleSystem();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user