Hello,
To give a short explanation (and as I am sure you can tell, I am new in the field trying to make a game in my spare time).
I want the player to be able to switch between a first person Character and an RTS style camera pawn which in turn have different ways of interracting with the game. As a solution for this I have some code in the Level Blueprint which allows me to posses the different actors, and in the actors blueprint I switch the Mapping Context.
Since both use many of the same inputs such as Mouse Click in the Player Controller, I was thinking of simply setting an IF statement asking which pawn us currently being possesed, before running the remaining code. My problem is that my IF is always returning FALSE and I cannot figure out why. Is anyone kind enough to get me on the right track either by providing a solution here or suggest that I set all of this up in another way entirely.
Code that always returns false, even though the print string shows that it is the same actor as I have set in the == operator
Possesion code in the Level Blueprint.
Setting the mapping context for the possesed actor
1 Like
I think youâd find if you used âget player characterâ and then casted it to the relevant blueprint, youâd be ok.
If you want to use == then I guess you could use a âget classâ before it. But with âget player pawnâ, youâve already done a sort of implicit cast anyway ( because one of them is a character, not a pawn ).
I donât have that. I have Booleans in the controller. âIsCharacterâ I also have the pawn or character, update the controller reference when ever the pawn is spawned. That way the controller ALWAYS knows how to access the pawn or character. The Boolean tells the controller which character or pawn reference to access.
Itâs like a boss wanting to order workers around. The worker comes to the boss and says âHereâs my phone number. Iâm on the shift now. If you need to talk, call me directly.â
Rather than the boss asking âIs that guy Bob? Iâll try to call him.â
Thanks for the replies!
I went for the casting to the camera pawn for unit movement solution and it works like as I had hoped. It also saved me the hazzle of figuring out how create and set the values of the booleans in the level bluepint, while letting the Player Controller read those values. Probably a simple thing to do, but I am pretty green and I got too many ideas to try out when casting to the relevant actor7character/pawn did the trick.
I might come back for the boolean idea even if I donât use for the unit commands. It could be very useful for the controller to have a boolean of which pawn/character is possesed.
Once again, thaks everyone!