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"

[SOLVED] Moving two pawns with one PlayerController?

Hello all,

I'm having trouble figuring out the best way to do this.

I'm making a single player 2D game (I might want to network it later but for now that's outside of my scope) and for now I have a character and a pawn sharing a player controller. I need for the player to be able to move both the character and the pawn at the same time, bound to different keys (for example, move the character with the arrow keys and the pawn with wasd) They also must share a camera, specifically tied to the character. Gravity and animation must also still occur like normal while the pawn is moving, so no trading of control between the two actors.

My problem so far is the best I've been able to do is a trade; I can control both actors but only one at a time; so when I move the character, the pawn won't budge even if I'm holding d or a, and vice versa for the character with left and right. Animation also gets stuck while the character isn't possessed.

I'm using the Possess(); method in my custom playercontroller depending on which InputAxis is called (wasd is always tied to the pawn; arrow keys are always tied to the character). I move actors with AddMovementInput(); and the pawn does have a movement component that I added. I believe the problem may be related more to a playercontroller only being able to control one actor at a time (the one that's possessed) but I'm not positive.

An unrelated problem that might be throwing me off somewhere is if I don't add a bool check for possession it gunks up movement; actors move very slowly because of the constant possession and re-possession for some reason that I haven't been able to really trace yet.

I've considered routing inputs through an invisible "brain" actor but that ties back to my not really knowing how movement in Unreal works fully. I don't think AddMovementInput() will work with an unpossessed pawn (Please correct me if I'm wrong) and I'd rather keep my input code contained to the playercontroller class if possible.

tl;dr - I need help finding the best way to structure and route movement through two pawns - what's the best way to accomplish this?

Thanks! If you need any more details I'll be happy to provide them

Product Version: UE 4.10
Tags:
more ▼

asked Dec 13 '15 at 11:30 PM in C++ Programming

avatar image

Walnut
20 4 4 8

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

1 answer: sort voted first

After reading around some I found a solution

Give each pawn its own AI Controller (PlayerController should work fine too I think) and have a master PlayerController act like the "brain" which routes the commands to them. As long as each pawn has its own controller you can move them at the same time on controller index 0

Solved - and thanks!

more ▼

answered Dec 14 '15 at 08:47 PM

avatar image

Walnut
20 4 4 8

(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