Download

Pawn possession

Hi, how do I properly switch possession between 2 pawns, RedPawn and BluePawn, if they are derived from same “BasePawn” parent class? Switching is done by keyboard input (left shift) and the way I thought of doing it is very weird, I don’t know the easier/better way to do this. Here is how I planned to do it, on paper.

  1. In GameMode I will create 2 references, 1 for RedPawn and 1 for BluePawn, and I will make 2 functions. First function will change possession between Red and Blue pawn and other function will switch a bool variable that determines which pawn will be possessed on next keyboard press.
  2. In BasePawn I will create a reference of GameMode object so I can call the 2 created functions. First function is called on keyboard press, second is called on keyboard release.

This will most likely work, but everything goes trough GameMode. I was wondering if my thought process was good, or if someone can tell me the better way to do it. Sorry, very new to UE4 blueprints and C++.

Thanks in advance!