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 to use a player controller to control a pawn?

Hi,

Currently I am using default player controllers. I posses every controller to a pawn, it's working. The problem is that the first controller is always controlling keyboard and gamepad. I want to change that by creating my own controller class that inherits from PlayerController.

But how does that binding between Pawn and PlayerController works in detail? Like what happens in detail if a keyboard key was pressed? And why is only the pawn with Controller0 is getting keyboard input? I assumed that the controller had a reference to the possessed pawn, but in the blueprints I cannot find anything like "GetPossessedPawn" or something...

blueprint

For a possible solution I was thinking about following idea (see image). The controller (must be the first controller) is getting Keyboard/Gamepad0 input. If the input is from the keyboard, the command gets delegated to the "keyboard" pawn. If its not from the keyboard, the possessed pawn is getting that command. This idea has some problems:

  1. There is no "GetPossessedPawn" function.

  2. This must be done for every InputAction. No generic way... :(

  3. The difference between Pressed and Released must be handled

Any idea for a solution without the 3 problems?

Product Version: UE 4.10
Tags:
inputhandling.jpg (85.3 kB)
more ▼

asked Jan 14 '16 at 09:53 PM in Blueprint Scripting

avatar image

mcmatze
92 13 14 17

avatar image Ryan Darcey Jan 14 '16 at 09:58 PM

Check your default project settings:

https://docs.unrealengine.com/latest/INT/Engine/UI/ProjectSettings/index.html

and game mode settings:

https://docs.unrealengine.com/latest/INT/Gameplay/Framework/GameMode/index.html

You can set the pawn and controller types in there.

avatar image mcmatze Jan 15 '16 at 08:16 AM

You may misunderstood me. I am using the Inputs from the project settings and I am using my own GameMode where I set my Pawn and Controller. But how can I control my pawn in my controller? I updated my question, maybe it's clearer now?

avatar image Ryan Darcey Jan 15 '16 at 05:49 PM

Sorry, not sure what you mean by "how can I control my pawn in my controller". Are you just trying to access the pawn your controller is currently assigned to?

avatar image mcmatze Jan 16 '16 at 10:48 PM

Yes, exactly. That is one of my problems. I tried to make my question clearer again, now with image.

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

1 answer: sort voted first

Player 1 will always be set to Controller0. Other players that join locally will be set to Controller1, Controller2, etc. As far as getting the pawn that will be controlled, you can use "Get Controlled Pawn" and send inputs to that actor.

more ▼

answered Jan 16 '16 at 11:33 PM

avatar image

renderman09
162 11 13 24

avatar image Shadowriver Jan 17 '16 at 04:14 AM

One note PlayerControllers don't have index, the "Get Controlled Pawn" get controller based of order index which may change

(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