Switching possession between two pawns.

Hey! Thanks a lot for providing help, GeekyPayback, I truly thank you.
Paul88, you clearly didn’ t answer to my question rather pointed out that I shouldn’t separate my code into classes? - you know how this will end - the code will be ugly and there will be problems understanding the code you wrote… Also… your code will turn into a large spaghetti code monster.
I know about the principles of OO programming, but then again… yes, I’ve got much to learn as UE4 is a really large quantity of stuff I’ve not been aware of, but offers so much at the same time.

Now about the problem I have. I have to ask few things for clarification:
Should I write the possession logic into gamemode class - is this basically the main class where the game logic stays?
I created my own playercontroller and I understood it is not neccessary. How am I supposed to get the exact instance of the playercontroller when I want to switch possession? there are two PaperCharacters in the game, they both have different playercontroller instances then?

Here’s how I’ve written my possession code in my gamemode class now - I call this function frame by frame in Tick function. Right now I’ve eliminated some dumb extra conditions I was trying to create there. So right now, it’s just running this function over and over.


I’ve overriden this function to use my playercontroller.

Here’s the destroy function I wrote. I read that K2_DestroyActor() function calls out DestroyActor() function (and is somewhat better than DestroyActor() function), so I should use this instead… and after that I of course use garbagecollection. Otherwise there will be some kind of empty object (which I had problem with) till the next garbagecollection.
392c1cf166e276c64fad1c8f62144de0.png

Oh and if I create those functions in my character classes, how am I supposed to call them in my gamemode class? I don’ t create any objects in my gamemode right now. One of them is created by setting the class as defaultpawn and the other gets spawned once I press a certain button.

Anyways. Here’s the stuff I’ve been doing lately. I need answer for my first questions. This could show me alot what to do next :slight_smile:
Thanks again!