Hi guys,
So I’m trying to implement my version of networked pathfinding, and the way I’m implementing it is by spawning an invisible pawn that mimics my character movements and rotation, but as soon as I click to move my AICONTROLLER would tell the invisible pawn to pathfind to the location (while having my character mimic its location/rotation).
So I have the following:
PlayerController.cpp
-Clicktomove → LocationToMove : sends the mouse click location to my character (mage)
Mage.cpp
// While true the player copies the AI's movement, true when we clickToMove in playerController.cpp
bool bPathFind;
// Spawn the proxy with invisible mesh at the Mage's location
AAPawn* characterProxy;
// Possess the proxy with an AI controller
AAIController* proxyController
proxyController->possess(characterProxy)
// Move the AI to the location
LocationToMove(FVector location) { proxyController-> MoveToLocation(location); }
But of course my AI does not move (the function gets called fine, but he simply will not move to the location)
To clarify things a little better here is my tick function, that decides which pawn mimics what:
// Called every frame
void AMageCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (characterProxy)
{
// Keep the Proxy in sync with the real character
FTransform CharTransform = characterProxy->GetTransform();
FTransform MyTransform = GetTransform();
FTransform Transform;
if (bPathFind)
{
//Player mimics the proxyAI
Transform.LerpTranslationScale3D(MyTransform, CharTransform, ScalarRegister(0.5f));
}
else
{
// ProxyAI copies the character to ensure he is around when we click to move
Transform.LerpTranslationScale3D(CharTransform, MyTransform, ScalarRegister(0.5f));
}
SetActorTransform(Transform);
}
}
Thanks in advance,