I’m trying to control 2 pawns with each thumbstick on my 360 gamepad. I’ve managed to setup inputs correctly when pawns are in scene by themselves. However, when I spawn first one via player spawn and spawn other pawn through level blueprint I can’t control one I spawn through level blueprint. It is stuck in air and won’t listen to any input.
I’ve checked answers from similar questions but haven’t been able to make anything work.
I’m pretty new to UE4 so there might be something small I miss, so I’m glad to get as much help as possible.
You need to make sure that second pawn you spawn has a Player Controller possessing it, or it will not respond to input using CharacterMovement component. Since you are attempting to use two pawns with same gamepad, you’ll need to give second pawn its own Controller; Player Controllers can only possess one pawn at a time. I was able to set this up by spawning a second Controller, then spawning second pawn, and possessing second pawn with second controller, like this:
I have this set in main Controller I’m using for first pawn rather than Level Blueprint, because it’s generally cleaner to avoid using Level Blueprint for things that do not pertain specifically to that level, but this should work in Level BP if that’s how you prefer to do it. Note that this is a very basic setup and can be elaborated on depending on your goals.
Hope this helps! Let me know if you have any questions.
It’s difficult to see what you’re trying to achieve with this setup. Are you trying to control 2 pawns in a single player game? If not, please open a new post with your question.
If you are trying to allow one player to control two pawns as this post is about, there are two problems with this setup. First, you’re using same input multiple times. By default, one of these inputs will override other. You can fix that by chaining Add Controller Yaw and Pitch input nodes, or by selecting Input nodes and disabling Consume Input in Details pane.
Second, you’re using Get Player Controller at Player Index, which returns Player Controller for multiple players. If you’re trying to make a single player game, Get Player Controller at Player Index 1 will return NULL. Instead, you should be getting a reference to a separate controller and its pawn for your second input. There are details on this type of setup in images for answer below.
Hi thanks for answer.
I’m making a first person single player game. there’s a situation where character get cloned to solve puzzles. so I was trying to get input from player controller 0 to control clone character too, so they have same rotation and use same input to walk and jump.
I got rotation working using a “Set Actor Rotation” node on a Tick event copying rotation of index 0 player.
Sorry i have been off this project for a while so i just tried your solution but hmm… i cant get it to work,99.999% sure its my fault.
it again just spawns one character that i control with my right stick, nothing els works. help please maybe?
Make sure that Transform for spawned character is valid, and that it isn’t colliding with anything or spawning somewhere you can’t see.
Your variable names are a bit confusing. It looks like you have it set up correctly, but you’re naming your spawned Controller Rmycharacter and your spawned Character Brothercontroller. I don’t think this is causing problem, but it will be harder to manage later as your project gets more complex.
Make sure controller you’re spawning is empty. You’re not actually using it to move character.
You’re getting Control Rotation of Controller rather than Pawn for right stick character. Drag off Get Controlled Pawn and search for Get Control Rotation for correct node.
For left stick character, you need to use variable you’re referencing character with, in this case Brothercontroller. I’m not sure what NewVar0 is referencing. Replace that with Brothercontroller. You also need to get Control Rotation from Brothercontroller rather than from controller. Reference solution image I posted above.
Oke thank you very much, it took me a while but i got all your tips worked out and fitted in my blueprint. then i got some errors from a constructionscript that i didnt use, something to do with ''get controlledpawn" node.it spawned 2 characters but only left one was controlled…
so tried to replace that with a direct reference to character, got same error… replaced it with ‘‘get controlledpawn’’ again to make a new screenshot to share for more help. but then hey error gone, and it works now
now its time to make a decent camera setup…
thanks again!
(Edit:
error is still there, but it works so who is complaining :D)
(Editedit: oke forget all i said, it seems it only works if i first, simulate, and then posses… otherwise i just take a camera view half in ground and i still can only control one character…)
If camera view is “half in ground”, then it’s likely you’re spawning at an invalid transform, or that you’re possessing wrong thing. Can you post a new screenshot of what your Blueprint looks like? And is this your Character BP or Controller BP?
If you’d like to upload project to Dropbox and send me a download link, I can take a look.
it looks like each time i press play it just spawns 2 cameras, that then disrepair again after i stop run… and error from construction script is in my controller.
Thanks for having a look, you are about only thing that is keeping my dream alive for now.
In your LMyChacter BP, set Auto Possess to Disabled in Defaults. What’s happening is you’re auto-possessing new character as soon as it is spawned without properly un-possessing default pawn. There’s no reason to auto-possess either of your characters, so if you set both to disabled this should work way you want.
Hello.
I’m using ue 4.8.0 and have problem do get it work. I’ve done step by step from this tutorial that seems equal to answer in this problem, but I can only control one character and after few hours trying to fix it I get nothing. Can ayone say what could be wrong?
I would need to take a look at your project to see how it differs from what I’ve shown in answer. If you upload it somewhere like Google Drive or Dropbox and give me a download link, I can look into it.
Hi everyone, I’m resurrecting this to let you know I’ve come up with an alternative solution. I’m uploading it now and will edit this post when it’s finished - I’m saying this because I don’t see a “It’s working” post and so I want to help future people if this doesn’t solve their problem.
could it be, that Solutions and Video Solution aswell (https://www…com/watch?v=YMHOIQJyEKY), are outdated since 4.8 and 4.9? People in Video Comments have same Problem like me.
First Char moves, but second one doesn’t. There is not much space for erros, specially if you follow all answers here.
Could someone of guys, who get it worked, make a copy and update project to 4.8 or 4.9 and tell us, if its still works?
I don’t believe Add Movement Input is currently working with controllers not controlled by player, as used in this setup. I have entered a bug report for this (UE-22094) and I’ll post here if I see an update. If I find that this is new expected behavior, I will attempt to find a different workaround. In meantime, KitatusStudios has a solution noted above that uses Pawns and a different movement solution that may help.
Hi, I’ve been investigating this with provided sample project.
It does look like something in code changed (possibly in 4.8)-- there is a “IsLocalController()” check we use to determine if CharacterMovementComponent is allowed to apply input, which has been there forever, but internals of that function have changed over time. second player controller is not bound to a “Player”, so it fails this test. I’m looking in to making code more flexible in this case, so that standalone games don’t check this and consider it a local controller.
Another very simple workaround here is to not use a controller at all for this other Pawn (or at least not possess it if you really need it), and set CharacterMovement “bRunPhysicsWithNoController” to true. This allows movement on pawn with no controller.