x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I control 2 pawns with 1 controller?

I'm trying to control 2 pawns with each thumbstick on my 360 gamepad. I've managed to setup the inputs correctly when the pawns are in the scene by themselves. However, when I spawn the first one via the player spawn and spawn the other pawn through the level blueprint I can't control the one I spawn through the level blueprint. It is stuck in the air and won't listen to any input.

I've checked the 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.

alt text

Product Version: Not Selected
Tags:
more ▼

asked Aug 22 '14 at 10:53 PM in Blueprint Scripting

avatar image

Grillet
6 2 3 5

avatar image gustavorios2 Nov 08 '14 at 03:03 PM

I got walk and jump working but I cant get the character to rotate by mouse =(

alt text

avatar image Ben Halliday STAFF Nov 08 '14 at 06:31 PM

Hey gustavorios2,

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 the same input multiple times. By default, one of these inputs will override the other. You can fix that by chaining the Add Controller Yaw and Pitch input nodes, or by selecting the Input nodes and disabling Consume Input in the Details pane.

Second, you're using Get Player Controller at Player Index, which returns the 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 the images for the answer below.

avatar image gustavorios2 Nov 08 '14 at 07:36 PM

Hi ben thanks for the answer. I'm making a first person single player game. there's a situation where the character get cloned to solve puzzles. so I was trying to get the input from the player controller 0 to control the clone character too, so they have the same rotation and use the same input to walk and jump.

I got the rotation working using a "Set Actor Rotation" node on a Tick event copying the rotation of the index 0 player.

everything is working fine now =)

alt text

alt text

3563743422.jpg (365.4 kB)
5656434777.jpg (100.4 kB)
avatar image hAgi Jun 21 '15 at 01:10 AM

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?

Tutorial links: part 1 part 2

avatar image Ben Halliday STAFF Jun 23 '15 at 10:10 PM

Hi hAgi,

I would need to take a look at your project to see how it differs from what I've shown in the answer. If you upload it somewhere like Google Drive or Dropbox and give me a download link, I can look into it.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey Grillet,

You need to make sure that the second pawn you spawn has a Player Controller possessing it, or it will not respond to input using the CharacterMovement component. Since you are attempting to use two pawns with the same gamepad, you'll need to give the 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 the second pawn, and possessing the second pawn with the second controller, like this:

alt text

I have this set in the main Controller I'm using for the first pawn rather than the Level Blueprint, because it's generally cleaner to avoid using the Level Blueprint for things that do not pertain specifically to that level, but this should work in the 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.

twopawnmovement.png (372.4 kB)
more ▼

answered Aug 23 '14 at 07:59 PM

avatar image Grillet Aug 28 '14 at 07:49 PM

Thank you. Works just fine now :)

avatar image Runehorn Jan 17 '15 at 04:50 PM

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?

here is what i got so far: alt text

mycontroller.jpg (487.1 kB)
avatar image Ben Halliday STAFF Jan 17 '15 at 05:14 PM

There's a few things you can check:

  1. Make sure that the Transform for the spawned character is valid, and that it isn't colliding with anything or spawning somewhere you can't see.

  2. 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 the problem, but it will be harder to manage later as your project gets more complex.

  3. Make sure the controller you're spawning is empty. You're not actually using it to move the character.

  4. You're getting the Control Rotation of the Controller rather than the Pawn for the right stick character. Drag off the Get Controlled Pawn and search for Get Control Rotation for the correct node.

  5. For the left stick character, you need to use the variable you're referencing the character with, in this case Brothercontroller. I'm not sure what NewVar0 is referencing. Replace that with Brothercontroller. You also need to get the Control Rotation from the Brothercontroller rather than from the controller. Reference the solution image I posted above.

Hope that helps!

avatar image Runehorn Jan 19 '15 at 02:04 PM

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 the ''get controlledpawn" node.it spawned 2 characters but only the left one was controlled... so tried to replace that with a direct reference to the character, got the same error... replaced it with the ''get controlledpawn'' again to make a new screenshot to share for more help. but then hey error gone, and it works now :D 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 the ground and i still can only control one character...)

avatar image Ben Halliday STAFF Jan 19 '15 at 09:55 PM

Hey Runehorn,

If the camera view is "half in the ground", then it's likely you're spawning at an invalid transform, or that you're possessing the 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 the project to Dropbox and send me a download link, I can take a look.

avatar image Runehorn Jan 19 '15 at 11:11 PM

hay here is a link to my project: https://www.dropbox.com/s/ea0h61yb0la9g4t/MyProject7.rar?dl=0 it looks like each time i press play it just spawns 2 cameras, that then disrepair again after i stop the run... and the error from the construction script is in my controller. Thanks for having a look, you are about the only thing that is keeping my dream alive for now.

avatar image Ben Halliday STAFF Jan 21 '15 at 03:36 PM

In your LMyChacter BP, set Auto Possess to Disabled in the Defaults. What's happening is you're auto-possessing the new character as soon as it is spawned without properly un-possessing the default pawn. There's no reason to auto-possess either of your characters, so if you set both to disabled this should work the way you want.

avatar image KITATUS Aug 22 '15 at 07:06 PM

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.

Solution: CLICK HERE

avatar image Croatoan Oct 10 '15 at 11:30 PM

How would you implement that with animated characters? I am trying to do something like this in a sidescroller template, no luck so far.

avatar image Spaehling Oct 12 '15 at 11:35 AM

Hey Guys,

could it be, that the Solutions and the Video Solution aswell (https://www.youtube.com/watch?v=YMHOIQJyEKY), are outdated since 4.8 and 4.9? The People in the Video Comments have the same Problem like me.

First Char moves, but second one doesn't. There is not much space for erros, specially if you follow all the answers here.

Could someone of the guys, who get it worked, make a copy and update the project to 4.8 or 4.9 and tell us, if its still works?

Greetz Spähling

avatar image Ben Halliday STAFF Oct 13 '15 at 09:21 PM

I don't believe Add Movement Input is currently working with controllers not controlled by the 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 the new expected behavior, I will attempt to find a different workaround. In the meantime, KitatusStudios has a solution noted above that uses Pawns and a different movement solution that may help.

avatar image Spaehling Nov 06 '15 at 03:31 PM

Thx man, yeah i watched into kitarus solution a while ago. looked pretty complex, but yeah give it a try soon again.

yeah, would be nice if you keep up the information about this. :)

avatar image zeroexception STAFF Dec 07 '15 at 10:39 PM

Hi, I've been investigating this with the 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 the CharacterMovementComponent is allowed to apply the input, which has been there forever, but the internals of that function have changed over time. The second player controller is not bound to a "Player", so it fails this test. I'm looking in to making the 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 the pawn with no controller.

avatar image Spaehling Dec 16 '15 at 04:13 PM

hey zak,

great to hear this answer. gonna check it out soon. still finishing another project this week. after that i bring my focus back to this.

after this few weeks, i also asked myself if i really really need this 2 pawns 1 controller stuff. Well i test out your workaround and decide it after that :)

greetz and thanks!

avatar image Hide0t Jan 15 '17 at 01:15 AM

How do I control 2 characters with 1 input? This post offers an answer for 2 characters with 1 controller....

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

how to manage two pawns without a controller

more ▼

answered Feb 10 '16 at 09:04 AM

avatar image

Sergey Piddubny
1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question