diff --git a/Content/Assets/Materials/PP_Highlight.uasset b/Content/Assets/Materials/PP_Highlight.uasset new file mode 100644 index 0000000..278bc9c Binary files /dev/null and b/Content/Assets/Materials/PP_Highlight.uasset differ diff --git a/Content/Blueprints/Weapon/BP_AssaultRifle.uasset b/Content/Blueprints/Weapon/BP_AssaultRifle.uasset index 677e41e..e2d02ec 100644 Binary files a/Content/Blueprints/Weapon/BP_AssaultRifle.uasset and b/Content/Blueprints/Weapon/BP_AssaultRifle.uasset differ diff --git a/Content/Blueprints/Weapon/BP_GenadeLauncher.uasset b/Content/Blueprints/Weapon/BP_GenadeLauncher.uasset index 98a4c26..eb5c836 100644 Binary files a/Content/Blueprints/Weapon/BP_GenadeLauncher.uasset and b/Content/Blueprints/Weapon/BP_GenadeLauncher.uasset differ diff --git a/Content/Blueprints/Weapon/BP_Pistol.uasset b/Content/Blueprints/Weapon/BP_Pistol.uasset index d44bbb1..c4a505b 100644 Binary files a/Content/Blueprints/Weapon/BP_Pistol.uasset and b/Content/Blueprints/Weapon/BP_Pistol.uasset differ diff --git a/Content/Blueprints/Weapon/BP_RocketLauncher.uasset b/Content/Blueprints/Weapon/BP_RocketLauncher.uasset index f581fdd..2de14b7 100644 Binary files a/Content/Blueprints/Weapon/BP_RocketLauncher.uasset and b/Content/Blueprints/Weapon/BP_RocketLauncher.uasset differ diff --git a/Content/Blueprints/Weapon/BP_Shotgun.uasset b/Content/Blueprints/Weapon/BP_Shotgun.uasset index f3cea60..960bd33 100644 Binary files a/Content/Blueprints/Weapon/BP_Shotgun.uasset and b/Content/Blueprints/Weapon/BP_Shotgun.uasset differ diff --git a/Content/Blueprints/Weapon/BP_SniperRifle.uasset b/Content/Blueprints/Weapon/BP_SniperRifle.uasset index bbbf0f2..19ebe08 100644 Binary files a/Content/Blueprints/Weapon/BP_SniperRifle.uasset and b/Content/Blueprints/Weapon/BP_SniperRifle.uasset differ diff --git a/Content/Blueprints/Weapon/BP_SubmachineGun.uasset b/Content/Blueprints/Weapon/BP_SubmachineGun.uasset index 401e2fc..56ee940 100644 Binary files a/Content/Blueprints/Weapon/BP_SubmachineGun.uasset and b/Content/Blueprints/Weapon/BP_SubmachineGun.uasset differ diff --git a/Content/Maps/BlasterMap.umap b/Content/Maps/BlasterMap.umap index 51029f1..d73b8b8 100644 Binary files a/Content/Maps/BlasterMap.umap and b/Content/Maps/BlasterMap.umap differ diff --git a/Source/Blaster/Weapon/Weapon.cpp b/Source/Blaster/Weapon/Weapon.cpp index 6afba49..3d592cf 100644 --- a/Source/Blaster/Weapon/Weapon.cpp +++ b/Source/Blaster/Weapon/Weapon.cpp @@ -25,6 +25,10 @@ AWeapon::AWeapon() WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block); WeaponMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore); WeaponMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision); + + WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_BLUE); + WeaponMesh->MarkRenderStateDirty(); + EnableCustomDepth(true); AreaSphere = CreateDefaultSubobject(TEXT("AreaSphere")); AreaSphere->SetupAttachment(RootComponent); @@ -43,6 +47,14 @@ void AWeapon::GetLifetimeReplicatedProps(TArray& OutLifetimeP DOREPLIFETIME(AWeapon, Ammo); } +void AWeapon::EnableCustomDepth(bool bEnabled) +{ + if (WeaponMesh) + { + WeaponMesh->SetRenderCustomDepth(bEnabled); + } +} + void AWeapon::BeginPlay() { Super::BeginPlay(); @@ -145,6 +157,7 @@ void AWeapon::SetWeaponState(EWeaponState State) WeaponMesh->SetEnableGravity(true); WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); } + EnableCustomDepth(false); break; case EWeaponState::EWS_Dropped: if (HasAuthority()) @@ -157,6 +170,9 @@ void AWeapon::SetWeaponState(EWeaponState State) WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block); WeaponMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore); WeaponMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore); + WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_BLUE); + WeaponMesh->MarkRenderStateDirty(); + EnableCustomDepth(true); break; } } @@ -186,6 +202,7 @@ void AWeapon::OnRep_WeaponState() WeaponMesh->SetEnableGravity(true); WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); } + EnableCustomDepth(false); break; case EWeaponState::EWS_Dropped: WeaponMesh->SetSimulatePhysics(true); @@ -194,6 +211,9 @@ void AWeapon::OnRep_WeaponState() WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block); WeaponMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore); WeaponMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore); + WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_BLUE); + WeaponMesh->MarkRenderStateDirty(); + EnableCustomDepth(true); break; } } diff --git a/Source/Blaster/Weapon/Weapon.h b/Source/Blaster/Weapon/Weapon.h index 2896d49..3a3340b 100644 --- a/Source/Blaster/Weapon/Weapon.h +++ b/Source/Blaster/Weapon/Weapon.h @@ -66,6 +66,9 @@ public: UPROPERTY(EditAnywhere, Category = Combat) float FireDelay = .15f; + + // Enable or disable custom depth + void EnableCustomDepth(bool bEnabled); protected: virtual void BeginPlay() override; diff --git a/Source/Blaster/Weapon/WeaponTypes.h b/Source/Blaster/Weapon/WeaponTypes.h index 22c62dd..6857b6a 100644 --- a/Source/Blaster/Weapon/WeaponTypes.h +++ b/Source/Blaster/Weapon/WeaponTypes.h @@ -2,6 +2,10 @@ #define TRACE_LENGTH 80000 +#define CUSTOM_DEPTH_PURPLE 250 +#define CUSTOM_DEPTH_BLUE 251 +#define CUSTOM_DEPTH_TAN 252 + UENUM(BlueprintType) enum class EWeaponType: uint8 {