Hi there, wanted to make a system where you can switch between different play styles. I used the TopDownCharacter Template and wanted to make it so that you can press tab and then you would possess this character because by default I want to use the DefaultPawn. Later there would be several pawns to chose from, however I can’t get this possessing issue running…
Despite having it like the picture above shows, when I enter the game and hit tab which is represented by “InputAction ChangeMode” nothing happens and I don’t understand why…?
Can anyone help, why can’t I possess the desired pawn like that, what am I missing?
Thanks a lot for your help!
This code even get called, if it get called is new pawn valid?
Is game multiplayer or not?
Try to connect “Get player controller” to the target input.
With this kind of question there is noway anyone can help. Try to debug it first. Add a Print String statement after Possess and see if you have set all the references correctly. It could be anything from not having Top Down Pawn reference set, to not receiving user input in the first place.
Thanks for your replies. To make it clearer what I did.
I was following this tutorial and did a simpler version of what is described at 15min: Possession of Pawns - Unreal Engine 4 Blueprint Tutorial - YouTube
I created a new controller blueprint and a game mode in the 2d side scroller template just like he did, I do what you see in the picture above but nothing happens where in his video all works fine… I don’t understand why…?
And also, when I do it like described here: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/PossessPawns/Blueprints/index.html all works fine… but I want my controller blueprint to do it not the level blueprint because then I would have to do it over and over again in every single level I have… It must be possible to have my controller blueprint do the job but why is it not working??
this doesn’t work, I’m already using a controller blueprint
Finally! Well as I was suspecting I was missing a crucial node…
Apparently it is mandatory to get your “In Pawn” with a “Get All Actors Of Class” Array Node. Doesn’t make sense to me but well, it is what you have to do and then it works
Mark your question as resolved if you’ve worked it out
Well, I don’t really want to let this standing without adding information.
it is mandatory to get your “In Pawn” with a “Get All Actors Of Class” Array Node
It is not. Your Code didn’t work, because your “TopDownPawnReference” was empty (at least I think it was). A blue Reference variable is not the same as an Integer or Boolean Variable. It’s empty if you don’t fill it. In C++, this is called a Pointer and you need to understand how this works. Otherwise you will run into these problems every time.
Also, “GetAllActorsOfClass” is an expensive and lazy node. You need to setup a way where you spawn your Pawns and save the Reference to them which you can later access. Since you use the PlayerController as a central point for switching Pawns, you should use it to Spawn and Save references.
What is a Reference and why are the Blue nodes Empty (Accessed None)
References or Pointers are Variables that are pointing to ONE instance of an Actor in your Game. Simple example:
You have 10 Pawns spawns in your Game, you can save a Reference to ONE of them in these Variables. If you don’t save one into the Variable, it will be empty. From where should the variable know what Pawn you meant?
So you need to learn how to efficiently reference your Actors/Objects. For this, I can recommend you to watch this Stream Recap:
Watch it and rework your logic. "GetAllActorsOfClass" is not the way to go! If you have multiple Pawns in your Levels, this node will return all of them and you can't even make out which one is which, since they are not really ordered in that Array you get their.
Also if you don’t have a Pawn in your Level, this Node will return an Empty Array.
Well thanks a lot… I’ve made some chances since then but I do understand that I’m probably not yet doing the referencing thing properly. In any case I made it working properly with the “GetAllActorsOfClass” and I’m able to switch between as many pawns as I want to with this method.
But clearly I could do better than that, so thanks for the input. Also I already know the video you suggested but thanks anyway… In time, when I really need to rework the spawning and swapping between pawns system, I will update this post with the “better” solution!