Hello
Description:
I am trying to control a AI on the Client side only using the inbuild capabilities of the Engine.
More specifically, I have an actor that need to use the PerceptionSystem. My actor does not have controller and has the following components attached; UAIPerceptionStimuliSourceComponent
and UAIPerceptionComponent
It works fine on the Server Side (Listen Server) where Actors can perceived other Actors (sight) but on Client Side, no one can perceived no one …
What I found:
- The PerceptionComponent needs a
UAIPerceptionSystem
and aUAISystemBase
to works - Neither of
UAIPerceptionSystem
norUAISystemBase
seem to exist on Client Side UAISystemBase
seem to be instanced here:UWorld::CreateAISystem()
- The condition to be instanced looks like:
if (AISystem == NULL && UAISystemBase::ShouldInstantiateInNetMode(GetNetMode()) && PersistentLevel)
- The declaration and implementation of the fonction are:
static ENGINE_API bool ShouldInstantiateInNetMode(ENetMode NetMode);
bool UAISystemBase::ShouldInstantiateInNetMode(ENetMode NetMode)
{
UAISystemBase* AISystemDefaultObject = Cast<UAISystemBase>(StaticClass()->GetDefaultObject());
return AISystemDefaultObject && (AISystemDefaultObject->bInstantiateAISystemOnClient == true || NetMode != NM_Client);
}
- And finaly I found inside
UAISystemBase
/** Whether the AI system class should be spawned when connecting as a client */
UPROPERTY(globalconfig, noclear)
bool bInstantiateAISystemOnClient;
So this looks like what I want but how to set the value at TRUE
? (without modifying the Engine..)
Note: ShouldInstantiateInNetMode
is not virtual, so I cannot override it and bInstantiateAISystemOnClient
is private.
Note2: I think it is on the config file DefaultEngine.ini
to add:
[/Script/AIModule.AISystem]
bInstantiateAISystemOnClient=True
But it does not seem to work so I need a confirmation that it is the solution or not before continuing to dig …
Thanks a lot!