Add reworked Worker Enemy AI #3
@ -12,4 +12,5 @@ enum class EPatrolMovementEnum : uint8
 | 
			
		||||
{
 | 
			
		||||
	SLOWWALK UMETA(DisplayName = "Slow Walk"),
 | 
			
		||||
	WALK UMETA(DisplayName = "Walk"),
 | 
			
		||||
	SPRINT UMETA(DisplayName = "Sprint"),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -63,6 +63,9 @@ void AEnemyAIController::OnPossess(APawn* InPawn)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Blackboard->SetValueAsEnum("State",  static_cast<uint8>(EAIState::PASSIVE));
 | 
			
		||||
 | 
			
		||||
	Blackboard->SetValueAsFloat("AttackRadius", enemy->AttackRadius);
 | 
			
		||||
	Blackboard->SetValueAsFloat("DefendRadius", enemy->DefendRadius);
 | 
			
		||||
	
 | 
			
		||||
	//ensure(enemy->GetMovementComponent()->UseAccelerationForPathFollowing());
 | 
			
		||||
}
 | 
			
		||||
@ -149,9 +152,24 @@ void AEnemyAIController::OnPerceptionUpdated(const TArray<AActor*>& actors)
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			FAISenseID SightID = SightConfig->GetSenseID();
 | 
			
		||||
			FAISenseID HearingID = HearingConfig->GetSenseID();
 | 
			
		||||
			FAISenseID DamageID = DamageConfig->GetSenseID();
 | 
			
		||||
			FAISenseID SightID;
 | 
			
		||||
			FAISenseID HearingID;
 | 
			
		||||
			FAISenseID DamageID;
 | 
			
		||||
 | 
			
		||||
			if (SightConfig)
 | 
			
		||||
			{
 | 
			
		||||
				SightID = SightConfig->GetSenseID();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (HearingConfig)
 | 
			
		||||
			{
 | 
			
		||||
				HearingID = HearingConfig->GetSenseID();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (DamageConfig)
 | 
			
		||||
			{
 | 
			
		||||
				DamageID = DamageConfig->GetSenseID();
 | 
			
		||||
			}			
 | 
			
		||||
 | 
			
		||||
			if (stimulus.Type == SightID)
 | 
			
		||||
			{
 | 
			
		||||
@ -229,6 +247,11 @@ void AEnemyAIController::SetStateAsAttacking(AActor* target)
 | 
			
		||||
	SetState(EAIState::ATTACKING);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
AActor* AEnemyAIController::GetTargetActor()
 | 
			
		||||
{
 | 
			
		||||
	return Cast<AActor>(Blackboard->GetValueAsObject("TargetActor"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AEnemyAIController::SensedSight(AActor* actor, FAIStimulus& stimulus)
 | 
			
		||||
{
 | 
			
		||||
	EAIState CurrentState = static_cast<EAIState>(Blackboard->GetValueAsEnum("State"));
 | 
			
		||||
 | 
			
		||||
@ -76,6 +76,9 @@ public:
 | 
			
		||||
	UFUNCTION()
 | 
			
		||||
	void SetStateAsAttacking(AActor* target);
 | 
			
		||||
 | 
			
		||||
	UFUNCTION(BlueprintCallable)
 | 
			
		||||
	AActor* GetTargetActor();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
	void SensedSight(AActor* actor, FAIStimulus& stimulus);
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,12 @@ class NAKATOMI_API AEnemyCharacter : public ANakatomiCharacter
 | 
			
		||||
public:
 | 
			
		||||
	UPROPERTY(EditAnywhere, Meta = (AllowPrivateAccess = "true"))
 | 
			
		||||
	APatrolRoute* CurrentPatrolRoute;
 | 
			
		||||
 | 
			
		||||
	UPROPERTY(EditAnywhere)
 | 
			
		||||
	float AttackRadius = 300.0;
 | 
			
		||||
 | 
			
		||||
	UPROPERTY(EditAnywhere)
 | 
			
		||||
	float DefendRadius = 500.0f;
 | 
			
		||||
	
 | 
			
		||||
private:
 | 
			
		||||
	UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user