Add minion character & CAIController

This commit is contained in:
Caleb Buhungiro
2025-09-13 21:48:34 +08:00
parent 1676ed7135
commit 1ccb111012
6 changed files with 89 additions and 2 deletions

View File

@@ -91,3 +91,6 @@ ConnectionType=USBOnly
bUseManualIPAddress=False
ManualIPAddress=
[/Script/GameplayDebugger.GameplayDebuggerConfig]
CategorySlot5=Five

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,48 @@
// Multiplayer By Caleb
#include "AI/CAIController.h"
#include "Character/CCharacter.h"
#include "Perception/AIPerceptionComponent.h"
#include "Perception/AISenseConfig_Sight.h"
ACAIController::ACAIController()
{
PrimaryActorTick.bCanEverTick = true;
AIPerceptionComponent = CreateDefaultSubobject<UAIPerceptionComponent>("AI Perception Component");
SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>("Sight config");
SightConfig->DetectionByAffiliation.bDetectEnemies = true;
SightConfig->DetectionByAffiliation.bDetectFriendlies = false;
SightConfig->DetectionByAffiliation.bDetectNeutrals = false;
SightConfig->SightRadius = 1000.f;
SightConfig->LoseSightRadius = 1200.f;
SightConfig->SetMaxAge(5.f);
SightConfig->PeripheralVisionAngleDegrees = 100.f;
AIPerceptionComponent->ConfigureSense(*SightConfig);
}
void ACAIController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
SetGenericTeamId(FGenericTeamId(0));
if (const auto PawnTeamInterface{Cast<IGenericTeamAgentInterface>(InPawn)})
{
PawnTeamInterface->SetGenericTeamId(GetGenericTeamId());
}
}
void ACAIController::BeginPlay()
{
Super::BeginPlay();
}
void ACAIController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}

View File

@@ -0,0 +1,30 @@
// Multiplayer By Caleb
#pragma once
#include "CoreMinimal.h"
#include "AIController.h"
#include "CAIController.generated.h"
UCLASS()
class CRUNCH_API ACAIController : public AAIController
{
GENERATED_BODY()
public:
ACAIController();
virtual void OnPossess(APawn* InPawn) override;
protected:
virtual void BeginPlay() override;
public:
virtual void Tick(float DeltaTime) override;
private:
UPROPERTY(VisibleDefaultsOnly, Category="Perception")
UAIPerceptionComponent* AIPerceptionComponent;
UPROPERTY(VisibleDefaultsOnly, Category="Perception")
class UAISenseConfig_Sight* SightConfig;
};