Possessd other's pawn then can't get controller pawn(invaliad)

In ma case I have Two character with same Blueprint

I started game with one of the guy then click Q to switch other guy(possess it)

Then I in my AIController started to disable get the controller pawn(seems like controller pawn is invaliad),I really want to figure it out what’s wrong with my logic? thank u guys for looking my question.

I’m not sure I quite understand what’s going on. My understanding is:

  1. Start with Pawn A possessed.
  2. Swap to possess Pawn B by pressing Q.
  3. Try to grab controller associated w/ Pawn A, but it’s null.

Is that right?

Yes,do u know why it’s null?

As soon as you possess Pawn B, Pawn A will lose it’s controller reference (ie. it will be NULL). Pawn A is “unpossessed” at that point. Pawn A’s previous controller is now possessing Pawn B.

Maybe if you explain what you are trying to do, I can help you get there? Either way, hopefully you understand Pawn A’s controller is NULL at the time you are trying to access it.

I am make a game player can switch to play between two characters.for example at the begin time player controlled the man character then the girl character is follower(I am using UI Controller make the follower following the man character every tick ) but some time player want to switch other character(such like press Q) then he can possess the girl character instead of controlling man character. as soon as he controlled the girl character the man character would be a follower controlled by UI controller.

Let’s say you start as man and switch to girl. Sounds like you got that part working, right?

In order to go back, you just need to run the same logic you ran on the man, but run it from the girl’s blueprint. She’ll have a valid pointer to the controller.

In current time I am using same blueprint for man and girl. At the start of game everything goes well. I can control the man and the girl following ok and I can switch to the girl and controlled the girl . but the man can not following. and I found it’s because in the AI controller when I unpossessd the man then I can’t find the controlled pawn any more in the AI controller(in the below picture 3 print controlled pawn is invaliad )