Now here is the situation. In game mode blueprint, with Event Begin Play I create a second player. The ID for new controller is “-1” which is what the random number for “Create Player” node. (Making the ID 0 breaks everything)
What I need to do is, I need to assign my default controller to this newly created player aswell. I am creating a local multiplayer game where two players use one keyboard.
At the moment I fix my problem by casting to player characters in the game during the game time to tell them what to do, for example input A makes player one move while input B makes player two move because I cast to them during that time.
I believe this is a dirty way to fix as the game automaticaly creates 2 controllers even only one of them, the first one is being used. And I got 2 player starts. Here is the situation:
Controller 0 is created. His mood : =D I am doing everything yay!
Controller 1 is created because “Create Player” node in gamemode blueprint says so. His mood: =| U wot mejt.
I tried to fix this by telling Create Player node in gamemode blueprint to assign the controller 0 to it aswell, but this makes things goes mad. It seems Player 0 loses the controller by this way. At the moment I got a second controller that I want to get rid of, as it does nothing at all.
As I checked the answerhub, spawning controller actor doesn’t work. I am not on my computer right now so I can’t check it.
Long story short, how can I make one controller posses two players at the same time?
Thank you for your time and reading!
By putting -1, you imply you want the next free ControllerID to be used. When you specify, it actually takes that controllerID if it is available. Which 0 by default is taken.
When input is captured by an Actor, for example the Controller. It is consumed by this Actor, and other actors in the world cannot receive direct input. The way I resolved this was similar to what you did, On Event Tick for the other actors I wanted to control. If I were to change it now, I would have the events from the PlayerController call specific functions within the Actors I wanted the PlayerController to manipulate.
Hope that helps!
Hello Mr Peter,
This, as you said sounds reasonable. Maybe the Engine is not ready for this, or it’s not designed to have one controller for two or more, though the paragraph in this link that I will show says otherwise.
" By default, there is a one-to-one relationship between Controllers and Pawns; meaning, each Controller controls only one Pawn at any given time. This is acceptable for most types of games, but may need to be adjusted as certain types of games - real-time strategy comes to mind - may require the ability to control multiple entities at once. "
It says it is possible… in a quite tricky way. The paragraph is like a beautiful girl winking at you but wrapping her arm around another guy’s belly right after. And it seems there is no information or tutorial regarding how to do it.
Just my two cents. I am planning to put something on Marketplace, a Fighting Game Template, and I would like it to be proffessional as much as it can. Having a controller that doesn’t do anything is abit odd. What if this was a Real Time Strategy Game? Hundreds of controllers everywhere! D: