Switching possession between the pawns

Hello!

I need your help with possessing pawns in my game.

I have two pawns in my game:

  • the main player
  • the pawn that will appear when certain key is pressed and gets destroyed after 5 seconds after it’s created.

I’ve added the possession code in my gamemode class, where I use TObjectIterator to iterate over my PaperCharacters I have - there are and there will be only two of them in my game.

However, I don’ t know how to write logic for my possession behaviour. I was wondering whether I could add some boolean setters and getters in my playercontroller class, but I can’ t understand how to overwrite the playercontroller in my player class (derives from APaperCharacter class) for example.

I also wondered I could use somekind of PaperCharacter counter. Everytime when there are 2 PaperCharacters, the other character will be controlled and when there’ s 1 PaperCharacter, the player character will be controlled. However, it might use too much resource when it would have to count PaperCharacters every frame.

I’ve trying to understand this logic for 1 day already. Don’ t know what to do…
Thanks in advance!