Possessing and Unpossessing different pawn

Hi People, I have a main Character class in my Game and from this class two other characters inherit. The problem is when I press a key to unpossess a possessed and spawn a new pawn to possess that one, I possess the newly spawned pawn but can’t give it any input, it doesn’t move.
The movement code is done in Player Controller so I can use the controller universally for all characters.

you have to show your code to be able to troubleshoot.

If we can only guess, mine would be that you have some things happening in wrong order.

You have nodes to get the currently possessed pawn so you can first check that it is indeed possessed.

If that is true then why does it not recieve input is the question. If you have one that does receive input and one that does not, look and see what is different between the two. You can filter class defaults detail panel by only values that have been changed using the cog here:

image

edit: you said that input is completely handled in the controller and the possessed pawn should be driven by that. So then input is not handled on the character, so disregard my above.
The question is that you are sending a transmission that is not getting recieved. So it seems likely that you are not actually possessing the pawn.


Please have a look. That properties are all same and I have print the possessed pawn’s name as well. I get the name of the possessed pawn but doesn’t move.

you are doing the same thing each time.

first you search the level for all actors of a class. There is no guarantee that they return in any specific order.

You unpossess all found actors of that class, which is not necessary.

Then you possess the first found actor.

So, most likely, you are just possessing the same actor again and again.

Instead of using the Get All node, you could have the pawns report themselves to the controller, and then you can select them with precision, and also avoid the costly Get All node.

The idea is to have a single actor report itself rather than search entire level. This is both more efficient and more precise.

You can do that by using an interface, or you could Get Player Controller → cast to your type → set some reference or call a function which adds reference to an array of references.

So if you set it up so that you have an array of references to your various pawns, then you can pick them out either by index, or use some other method to identify them. Like they might all have tags to identify them, or an enum, etc. Or if you just want to iterate through the array and possess them sequentially you could do that.

Okay, I understand what you’re saying. You see in photo what I’m doing and printed the name of my possessed pawn by the node “GetControlledPawn” in player controller and guess the player controller prints the name of possessed pawns. If I’m not possessing the other pawn why I’m looking through it’s camera and why “PrintString” is printing it’s name on screen using “GetControlledPawn”?

if you have confirmed that you are possessing the correct pawn, but it is not responding to your input events, the next step is to try and confirm if the message being sent is being received.

So how is it that input goes from the controller to the character/pawn? You can use breakpoints or print logs to see if the connection is being made or not.

After Possess try to use Enable Input:

I can’t figure out the issue but I’ll see what can be done

@SolidSk It didn’t work either

In your Pawn’s Blueprint check Auto Possess Player and Auto Receive Input if it is set to Player 0.

@SolidSk I’m going to die, couldn’t figure this out.

well you should be making more of an effort at troubleshooting than the people helping you. You still havent answered the essential questions I asked like two days ago!

Troubleshooting is not just guessing at random things. You have to show the code - all of it - and work through it logically. We still have no idea how you are handling input at all and the code you did show doesn’t make any sense.

1 Like


@BIGTIMEMASTER Please check this out. I have two characters in my game and I’m getting their reference in the Level Blueprint, Print Screen shows the newly possessed pawn but I can still move the Blue Ring in front of the character of the previous pawn however I can’t move it.

This confirms that the possessing is happening correctly.

The next step is to figure out what is happening with the input then. So we should take a look at both where input is handled and where it is sent.

It would be a good idea to look both at the working pawn and the one that has problems, as well as the player controller.

How do I debug that? I mean I’m possessing the other one. How do I test if Input is sent to it?

how are you doing it in the working one?

Yes, the default one, set in GameMode.

that does not look like the default unreal template character to me. I have no idea then how input gets from the player controller to the character. It’s no good to just guess. Have to see the code.

I didn’t say it’s default character, By default I mean that I set the default character in Game Mode “Default Pawn” which is the man on horse you see.