Highlight Enemies
This commit is contained in:
@ -46,6 +46,7 @@ r.DynamicGlobalIlluminationMethod=1
|
||||
r.ReflectionMethod=1
|
||||
r.Shadow.Virtual.Enable=1
|
||||
r.DefaultFeature.AutoExposure.ExtendDefaultLuminanceRange=True
|
||||
r.CustomDepth=3
|
||||
|
||||
[/Script/WorldPartitionEditor.WorldPartitionEditorSettings]
|
||||
CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet'
|
||||
|
BIN
Content/Blueprints/Character/ABP_Enemy.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Character/ABP_Enemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Character/Enemy/Animation/ABP_Enemy.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Character/Enemy/Animation/ABP_Enemy.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Character/Enemy/BP_EnemyBase.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Character/Enemy/BP_EnemyBase.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Character/Enemy/GoblinSlingshot/Animation/ABP_GoblinSlingshot.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Character/Enemy/GoblinSlingshot/Animation/ABP_GoblinSlingshot.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Character/Enemy/GoblinSlingshot/BP_GoblinSlingshot.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Character/Enemy/GoblinSlingshot/BP_GoblinSlingshot.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Character/Enemy/GoblinSpear/Animation/ABP_GoblinSpear.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Character/Enemy/GoblinSpear/Animation/ABP_GoblinSpear.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Character/Enemy/GoblinSpear/BP_GoblinSpear.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Character/Enemy/GoblinSpear/BP_GoblinSpear.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Maps/StartupMap.umap
(Stored with Git LFS)
BIN
Content/Maps/StartupMap.umap
(Stored with Git LFS)
Binary file not shown.
@ -4,3 +4,4 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#define CUSTOM_DEPTH_RED 250
|
||||
|
@ -2,4 +2,27 @@
|
||||
|
||||
|
||||
#include "Character/AuraEnemy.h"
|
||||
#include "Aura/Aura.h"
|
||||
|
||||
AAuraEnemy::AAuraEnemy()
|
||||
{
|
||||
GetMesh()->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);
|
||||
|
||||
GetMesh()->SetRenderCustomDepth(false);
|
||||
GetMesh()->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED);
|
||||
|
||||
Weapon->SetRenderCustomDepth(false);
|
||||
Weapon->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED);
|
||||
}
|
||||
|
||||
void AAuraEnemy::HighlightActor()
|
||||
{
|
||||
GetMesh()->SetRenderCustomDepth(true);
|
||||
Weapon->SetRenderCustomDepth(true);
|
||||
}
|
||||
|
||||
void AAuraEnemy::UnHighlightActor()
|
||||
{
|
||||
GetMesh()->SetRenderCustomDepth(false);
|
||||
Weapon->SetRenderCustomDepth(false);
|
||||
}
|
||||
|
7
Source/Aura/Private/Interaction/EnemyInterface.cpp
Normal file
7
Source/Aura/Private/Interaction/EnemyInterface.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024
|
||||
|
||||
|
||||
#include "Interaction/EnemyInterface.h"
|
||||
|
||||
|
||||
// Add default functionality here for any IMyClass functions that are not pure virtual.
|
@ -4,12 +4,20 @@
|
||||
#include "Player/AuraPlayerController.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "Interaction/EnemyInterface.h"
|
||||
|
||||
AAuraPlayerController::AAuraPlayerController()
|
||||
{
|
||||
bReplicates = true;
|
||||
}
|
||||
|
||||
void AAuraPlayerController::PlayerTick(float DeltaTime)
|
||||
{
|
||||
Super::PlayerTick(DeltaTime);
|
||||
|
||||
CursorTrace();
|
||||
}
|
||||
|
||||
void AAuraPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
@ -52,3 +60,60 @@ void AAuraPlayerController::Move(const FInputActionValue& InputActionValue)
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraPlayerController::CursorTrace()
|
||||
{
|
||||
FHitResult CursorHit;
|
||||
GetHitResultUnderCursor(ECC_Visibility, false, CursorHit);
|
||||
if (!CursorHit.bBlockingHit) return;
|
||||
|
||||
LastActor = ThisActor;
|
||||
ThisActor = CursorHit.GetActor();
|
||||
|
||||
/**
|
||||
* Line trace from cursor. There are several scenarios:
|
||||
* A. LastActor is null && ThisActor is null
|
||||
* - Do nothing
|
||||
* B. LastActor is null && ThisActor is valid
|
||||
* - Highlight ThisActor
|
||||
* C. LastActor is valid && ThisActor is null
|
||||
* - UnHighlight LastActor
|
||||
* D. Both actors are valid, but LastActor != ThisActor
|
||||
* - UnHighlight LastActor, and Highlight ThisActor
|
||||
* E. Both actors are valid, and are the same actor
|
||||
* - Do nothing
|
||||
*/
|
||||
if (LastActor == nullptr)
|
||||
{
|
||||
if (ThisActor != nullptr)
|
||||
{
|
||||
// Case B
|
||||
ThisActor->HighlightActor();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case A - both are null, do nothing
|
||||
}
|
||||
}
|
||||
else // LastActor is valid
|
||||
{
|
||||
if (ThisActor == nullptr)
|
||||
{
|
||||
// Case C
|
||||
LastActor->UnHighlightActor();
|
||||
}
|
||||
else // both actors are valid
|
||||
{
|
||||
if (LastActor != ThisActor)
|
||||
{
|
||||
// Case D
|
||||
LastActor->UnHighlightActor();
|
||||
ThisActor->HighlightActor();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case E - do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,19 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AuraCharacterBase.h"
|
||||
#include "Interaction/EnemyInterface.h"
|
||||
#include "AuraEnemy.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class AURA_API AAuraEnemy : public AAuraCharacterBase
|
||||
class AURA_API AAuraEnemy : public AAuraCharacterBase, public IEnemyInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
AAuraEnemy();
|
||||
virtual void HighlightActor() override;
|
||||
virtual void UnHighlightActor() override;
|
||||
};
|
||||
|
27
Source/Aura/Public/Interaction/EnemyInterface.h
Normal file
27
Source/Aura/Public/Interaction/EnemyInterface.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "EnemyInterface.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE()
|
||||
class UEnemyInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class AURA_API IEnemyInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
virtual void HighlightActor() = 0;
|
||||
virtual void UnHighlightActor() = 0;
|
||||
};
|
@ -9,6 +9,7 @@
|
||||
struct FInputActionValue;
|
||||
class UInputAction;
|
||||
class UInputMappingContext;
|
||||
class IEnemyInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -21,6 +22,8 @@ class AURA_API AAuraPlayerController : public APlayerController
|
||||
public:
|
||||
AAuraPlayerController();
|
||||
|
||||
virtual void PlayerTick(float DeltaTime) override;
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
@ -34,4 +37,8 @@ private:
|
||||
TObjectPtr<UInputAction> MoveAction;
|
||||
|
||||
void Move(const FInputActionValue& InputActionValue);
|
||||
|
||||
void CursorTrace();
|
||||
TScriptInterface<IEnemyInterface> LastActor;
|
||||
TScriptInterface<IEnemyInterface> ThisActor;
|
||||
};
|
||||
|
Reference in New Issue
Block a user