Hello, I have a wired issue where when I get the player controller ID of the possessed character, it returns -1. Even tho its set to auto possess as player 0.
Can anyone explain whats going on?
Heres an image of the eventBeginPlay blueprint that does reads it.
Ok, Raildex from discord gave me the important help. I need to plug in a player to get player controller ID. Now since this happens on the characterBP and I have several of those in the world (as im also using the same blueprint for npcs atm) I thought there was a way to have the blueprint know which ID its been possessed at (in my single player game that would always be 0) so I can know which of the characters is posessed and load the player settings to that instance only.
But it turns out, its not a wise thing to do that based on hardcoded playerIndex so Ill instead use the event Possessed to load the player stats to only the posessed character. I might need to add a few extra things, so that it only does it to the first character you possess starting the game, not any other that a you might possess later during gameplay.
Quick question here then: whats the order of the events execute when I start the game posessing a character, does it first execute begin play and then event possessed? (would make sense)
Thanks for replying here too mate. Alright, heres what I want to do:
I have made a characterBlueprint that holds my main character, but that same blueprint also has ability to become an npc (which uses the same skeleton).
So I place it 2 times in the scene, one for the player character and one for the npc (which only has to stand around in idle).
What the f. is going on there? I know that the other blueprint (maya_characterBP2) gets posessed by the AI as per Auto Posess AI = Placed in World so it prints one. I have tried disabling that and as a result that doesnt print anything.
But Why exactly is my player print twice? Even if I set the Auto Possess AI to disabled, it STILL prints itself twice, it has to be executing event possessed twice, but why?
And what If I want to execute a function ONLY on player possess, not on AI possess? How to tell the blueprint it is the one owned by the player so only it does something and none of the other copies of it that may be in the world.
I recommend using interfaces for this and delegating the functions from the Player-/AI-Controller to the Pawn.
To solve your problem, OnPosses, you get a Controller Reference. Cast it to PlayerController and do your Player Stuff.
If the Cast Fails, Cast to AIController and do your AI stuff.