parent
7d6d6ed497
commit
1de94528c8
|
@ -47,6 +47,10 @@ r.DynamicGlobalIlluminationMethod=1
|
||||||
r.ReflectionMethod=1
|
r.ReflectionMethod=1
|
||||||
r.Shadow.Virtual.Enable=1
|
r.Shadow.Virtual.Enable=1
|
||||||
r.CustomDepth=3
|
r.CustomDepth=3
|
||||||
|
r.Streaming.LimitPoolSizeToVRAM=1
|
||||||
|
r.Streaming.PoolSize=0
|
||||||
|
r.MSAACount=2
|
||||||
|
r.AntiAliasingMethod=2
|
||||||
|
|
||||||
[/Script/WorldPartitionEditor.WorldPartitionEditorSettings]
|
[/Script/WorldPartitionEditor.WorldPartitionEditorSettings]
|
||||||
CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet'
|
CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet'
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/_Game/Maps/DefaultMap.umap (Stored with Git LFS)
BIN
Content/_Game/Maps/DefaultMap.umap (Stored with Git LFS)
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "BulletHitInterface.h"
|
||||||
|
|
||||||
|
// Add default functionality here for any IBulletHitInterface functions that are not pure virtual.
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "UObject/Interface.h"
|
||||||
|
#include "BulletHitInterface.generated.h"
|
||||||
|
|
||||||
|
// This class does not need to be modified.
|
||||||
|
UINTERFACE(MinimalAPI)
|
||||||
|
class UBulletHitInterface : public UInterface
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SHOOTER_API IBulletHitInterface
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||||
|
public:
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||||
|
void BulletHit(FHitResult HitResult);
|
||||||
|
};
|
|
@ -0,0 +1,51 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Enemy.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "Sound/SoundCue.h"
|
||||||
|
#include "Particles/ParticleSystemComponent.h"
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
AEnemy::AEnemy()
|
||||||
|
{
|
||||||
|
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
void AEnemy::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
GetMesh()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Visibility, ECollisionResponse::ECR_Block);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
|
void AEnemy::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called to bind functionality to input
|
||||||
|
void AEnemy::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||||
|
{
|
||||||
|
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEnemy::BulletHit_Implementation(FHitResult HitResult)
|
||||||
|
{
|
||||||
|
if (ImpactSound)
|
||||||
|
{
|
||||||
|
UGameplayStatics::PlaySoundAtLocation(this, ImpactSound, GetActorLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImpactParticles)
|
||||||
|
{
|
||||||
|
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ImpactParticles, HitResult.Location, FRotator(0.f), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BulletHitInterface.h"
|
||||||
|
#include "GameFramework/Character.h"
|
||||||
|
#include "Enemy.generated.h"
|
||||||
|
|
||||||
|
class UParticleSystem;
|
||||||
|
class USoundCue;
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class SHOOTER_API AEnemy : public ACharacter, public IBulletHitInterface
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this character's properties
|
||||||
|
AEnemy();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
/** Particles to spawn when hit by bullets */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true))
|
||||||
|
UParticleSystem* ImpactParticles;
|
||||||
|
|
||||||
|
/** Sound to play when hit by bullets */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true))
|
||||||
|
USoundCue* ImpactSound;
|
||||||
|
public:
|
||||||
|
// Called every frame
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
// Called to bind functionality to input
|
||||||
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||||
|
|
||||||
|
virtual void BulletHit_Implementation(FHitResult HitResult) override;
|
||||||
|
};
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Explosive.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "Sound/SoundCue.h"
|
||||||
|
#include "Particles/ParticleSystemComponent.h"
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
AExplosive::AExplosive()
|
||||||
|
{
|
||||||
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
void AExplosive::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
|
void AExplosive::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExplosive::BulletHit_Implementation(FHitResult HitResult)
|
||||||
|
{
|
||||||
|
if (ExplosionSound)
|
||||||
|
{
|
||||||
|
UGameplayStatics::PlaySoundAtLocation(this, ExplosionSound, GetActorLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ExplosionParticles)
|
||||||
|
{
|
||||||
|
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionParticles, HitResult.Location, FRotator(0.f), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Apply explosive damage
|
||||||
|
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BulletHitInterface.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "Explosive.generated.h"
|
||||||
|
|
||||||
|
class UParticleSystem;
|
||||||
|
class USoundCue;
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class SHOOTER_API AExplosive : public AActor, public IBulletHitInterface
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this actor's properties
|
||||||
|
AExplosive();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/** Particles to spawn when hit by bullets */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true))
|
||||||
|
UParticleSystem* ExplosionParticles;
|
||||||
|
|
||||||
|
/** Sound to play when hit by bullets */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Combat, meta = (AllowPrivateAccess = true))
|
||||||
|
USoundCue* ExplosionSound;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Called every frame
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
virtual void BulletHit_Implementation(FHitResult HitResult) override;
|
||||||
|
};
|
|
@ -17,6 +17,7 @@
|
||||||
#include "Particles/ParticleSystemComponent.h"
|
#include "Particles/ParticleSystemComponent.h"
|
||||||
#include "Sound/SoundCue.h"
|
#include "Sound/SoundCue.h"
|
||||||
#include "Ammo.h"
|
#include "Ammo.h"
|
||||||
|
#include "BulletHitInterface.h"
|
||||||
#include "PhysicalMaterials/PhysicalMaterial.h"
|
#include "PhysicalMaterials/PhysicalMaterial.h"
|
||||||
#include "Shooter.h"
|
#include "Shooter.h"
|
||||||
|
|
||||||
|
@ -654,16 +655,29 @@ void AShooterCharacter::SendBullet()
|
||||||
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), EquippedWeapon->GetMuzzleFlash(), SocketTransform);
|
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), EquippedWeapon->GetMuzzleFlash(), SocketTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
FVector BeamEnd;
|
FHitResult BeamHitResult;
|
||||||
bool bBeamEnd = GetBeamEndLocation(SocketTransform.GetLocation(), BeamEnd);
|
bool bBeamEnd = GetBeamEndLocation(SocketTransform.GetLocation(), BeamHitResult);
|
||||||
|
|
||||||
if (!bBeamEnd) return;
|
if (!bBeamEnd) return;
|
||||||
|
|
||||||
// Spawn impact particles after updating BeamEndPoint
|
// Spawn impact particles after updating BeamEndPoint
|
||||||
if (ImpactParticles)
|
|
||||||
|
// Does hit actor implement BulletHitInterface?
|
||||||
|
IBulletHitInterface* BulletHitInterface = nullptr;
|
||||||
|
if (IsValid(BeamHitResult.GetActor()) &&
|
||||||
|
(BulletHitInterface = Cast<IBulletHitInterface>(BeamHitResult.GetActor())) != nullptr)
|
||||||
{
|
{
|
||||||
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ImpactParticles,
|
BulletHitInterface->BulletHit_Implementation(BeamHitResult);
|
||||||
BeamEnd);
|
UE_LOG(LogTemp, Warning, TEXT("actor particle"));
|
||||||
|
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("actor particle"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ImpactParticles)
|
||||||
|
{
|
||||||
|
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ImpactParticles,
|
||||||
|
BeamHitResult.Location);
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("normal particle"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn smoke trail particles
|
// Spawn smoke trail particles
|
||||||
|
@ -673,10 +687,9 @@ void AShooterCharacter::SendBullet()
|
||||||
SocketTransform);
|
SocketTransform);
|
||||||
if (Beam)
|
if (Beam)
|
||||||
{
|
{
|
||||||
Beam->SetVectorParameter("Target", BeamEnd);
|
Beam->SetVectorParameter("Target", BeamHitResult.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AShooterCharacter::PlayGunFireMontage()
|
void AShooterCharacter::PlayGunFireMontage()
|
||||||
|
@ -691,27 +704,28 @@ void AShooterCharacter::PlayGunFireMontage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AShooterCharacter::GetBeamEndLocation(const FVector& MuzzleSocketLocation, FVector& OutBeamLocation)
|
bool AShooterCharacter::GetBeamEndLocation(const FVector& MuzzleSocketLocation, FHitResult& OutHitResult)
|
||||||
{
|
{
|
||||||
|
FVector OutBeamLocation;
|
||||||
|
|
||||||
// Check for crosshair trace hit
|
// Check for crosshair trace hit
|
||||||
FHitResult CrosshairHitResult;
|
FHitResult CrosshairHitResult;
|
||||||
bool bCrosshairHit = TraceUnderCrosshairs(CrosshairHitResult, OutBeamLocation);
|
bool bCrosshairHit = TraceUnderCrosshairs(CrosshairHitResult, OutBeamLocation);
|
||||||
|
|
||||||
// Perform a second trace, this time from the gun barrel
|
// Perform a second trace, this time from the gun barrel
|
||||||
FHitResult WeaponTraceHit;
|
|
||||||
const FVector WeaponTraceStart{ MuzzleSocketLocation };
|
const FVector WeaponTraceStart{ MuzzleSocketLocation };
|
||||||
const FVector StartToEnd{ OutBeamLocation - MuzzleSocketLocation };
|
const FVector StartToEnd{ OutBeamLocation - MuzzleSocketLocation };
|
||||||
const FVector WeaponTraceEnd{ MuzzleSocketLocation + StartToEnd * 1.25f };
|
const FVector WeaponTraceEnd{ MuzzleSocketLocation + StartToEnd * 1.25f };
|
||||||
|
|
||||||
GetWorld()->LineTraceSingleByChannel(WeaponTraceHit, WeaponTraceStart, WeaponTraceEnd,
|
GetWorld()->LineTraceSingleByChannel(OutHitResult, WeaponTraceStart, WeaponTraceEnd,
|
||||||
ECollisionChannel::ECC_Visibility);
|
ECollisionChannel::ECC_Visibility);
|
||||||
|
|
||||||
if (WeaponTraceHit.bBlockingHit) // Object between barrel and BeamEndPoint ?
|
if (!OutHitResult.bBlockingHit) // Object between barrel and BeamEndPoint ?
|
||||||
{
|
{
|
||||||
OutBeamLocation = WeaponTraceHit.Location;
|
OutHitResult.Location = OutBeamLocation;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AShooterCharacter::TraceUnderCrosshairs(FHitResult& OutHitResult, FVector& OutHitLocation)
|
bool AShooterCharacter::TraceUnderCrosshairs(FHitResult& OutHitResult, FVector& OutHitLocation)
|
||||||
|
|
|
@ -104,7 +104,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
void FireWeapon();
|
void FireWeapon();
|
||||||
|
|
||||||
bool GetBeamEndLocation(const FVector& MuzzleSocketLocation, FVector& OutBeamLocation);
|
bool GetBeamEndLocation(const FVector& MuzzleSocketLocation, FHitResult& OutHitResult);
|
||||||
|
|
||||||
/* Set bAiming to true or false with button press */
|
/* Set bAiming to true or false with button press */
|
||||||
void AimingButtonPressed();
|
void AimingButtonPressed();
|
||||||
|
|
Loading…
Reference in New Issue