Simple Move not working with Possessed Characters

I’m making a system where you can controll multiple characters, switching between them by pressing a button, the game its a top down project where the characters move through a “Simple Move to Location” on a Player Controller, simple stuff, pretty much like the UE Template.

The issue here is, while i can normally controll the first Character that the Controller Possess, when i possess a diferent one the character just doesn’t move, i change characters again and again and they just don’t move, but when i finally change back to the first Character that the Controller possessed, it moves normally.

I tried to Un Possess the characters before doing the process but it doesn’t work, all Characters comes from a Parent with auto possess disabled and AI controll set to Placed on World or Spawned, but before that the simple system that does not work its that, when i possess a diferent character, the said character doesn’t move… maybe i’m forgeting something simple here or something like that and i’ll love some help from anyone out there.

This is a Simplified version of the current setup on the PlayerController that i have now…

1 Like

I don’t know yet but I would recommend replacing Length node with Last Index node as that will cause additional problems otherwise.

Good idea, don’t know if there’s any diference but that’s a better way to check the current character on the list.

depending on the situation you may net need to posses any of the characters. im imagining a click to move type situation so i may be off a bit, but if thats the case you can have the characters possesed by a ai controller and still move them from your player controller via a move to you just need a reference to the character you want to move.

heres a little example of what i was talking about. if you look at picture two below you will see the thirdperson character and a on clicked event which gets the player controller and sets the selectedChar variable to the character that was clicked. you can skip this in your case since you will have a list to work from. the first picture below shows the player controller which has a right mouse event which gets the location where i right click and moves the selected actor to that location. as long as you have a nav mesh volume it will work. course this is just a quick example for proof of concept.

Yep i though about that workaround while i was at work, didn’t try it cause i need to literally controll the character for diferent input and events, something that i will try today is destroying the character that the controller was possessing before possessing another one and creating a copy there, don’t know if it’ll work but at least it makes sense. I’m still curious though, even making it work i still want to know why a simple possess like that doesn’t tranfer that kind of movement controll to the character, but i guess that’s a question for Epic Games.

I’ll try to find a way to implement this work around when i get there first to see if its viable concidering all the other sistems on the game, thanks for the hint \o_

i just tried creating a setup as you initially described and it works fine in my case. are you sure you have a nav mesh bounds volume in you level. how are you actually moving the characters? the issue could be in your movement script.

Exactly, i did the same and it did work, but with my project it just didn’t. Had to make a system with a “Add movement input” after making a path to location today to get it to work without having to remake the entire blueprint from scratch, don’t realy know why it is happening specifically with Simple Move to Location, that’s what i’m going to try to discover today, but so far, the problem seems to be my project at work, and since the only thing that its not tranfered to my new possessed character its the movement, i bet its something wrong with the controller, i thoough it was the navmesh volume but its fine.

Fun fact, when i make the controller “Un possess” the character BEFORE possessing the next one, the inputs on the next possessed character work, but when i try to move him my old character move instead… crazy right? this just keeps getting more and more weird the more i look into it.

i did the same and it did work, but with my project it just didn’t.

so which is it? it did or didnt?

show us your movement script so we can make sure its not that. also did you ever fix your posses script it has a few issues in it. for example you are possesing the current character +1 which is good but your not ensuring its a valid character until after you posses, what i mean is that it could be index 5 when theres only 4 indexes.

inputs on the next possessed character work, but when i try to move him my old character move instead

so the inputs dont work then, or your script is getting the wrong character to move.

so which is it? it did or didnt?

It didn’t, that’s why i had to make a movement system from scratch, but here’s a test i did at home and at work

I created 2 projects, both Top Down Templates from Unreal, one in 4.19 and the other on 4.20, and did the same code on both projects

The Project made on 4.19 worked fine, while the 4.20 project just didn’t, don’t know what version you used there to replicate the issue but here that’s the results

I know this post was a long time ago but I hit the same problem and figured out what was going on.

The issue is that in a client navigation case the controller’s UPathFollowingComponent doesn’t get updated after possessing a new pawn with its new movement component. This happens because the UPathFollowingComponent normally gets the update from the Controllers GetOnNewPawnNotifier event which only fires on the server. This means that when SimpleMoveToLocation is called the check for PFollowComp->IsPathFollowingAllowed() fails (it has a null check on the movement component).

The workaround I went with (C++ required I’m afraid) is to implement a wrapper to SimpleMoveToLocation that reinitializes the Path Following Component if necessary, here’s an example:

void AMySamplePlayerController::SimpleClientNavMove(const FVector& Destination)
{
	UPathFollowingComponent* PathFollowingComp = FindComponentByClass<UPathFollowingComponent>();
	if (PathFollowingComp == nullptr)
	{
		PathFollowingComp = NewObject<UPathFollowingComponent>(this);
		PathFollowingComp->RegisterComponentWithWorld(GetWorld());
		PathFollowingComp->Initialize();
	}
	
	if (!PathFollowingComp->IsPathFollowingAllowed())
	{
		// After a client respawn we need to reinitialize the path following component
		// The default code path that sorts this out only fires on the server after a Possess
		PathFollowingComp->Initialize();
	}

	UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, Destination);
}
1 Like