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 get my current player's index?

Hey guys, I am working in the level blueprint and I am attempting to add an impulse to an object in the direction that my player is looking. However, it is going to be for a split screen game and I need the impulse to work with both my first player and second player independently, so when the first player adds the impulse it will go in the direction that he is looking and when the second player adds the impulse it will go in the direction that he is looking. As of now I have what is pictured below. This creates a problem when the second player attempts to impulse the object, as it goes in the direction that the first player is looking. Would there be a way to get the player index to set which player is impulsing the object so the rotation will be set accordingly? Thanks a lot!

alt text

Product Version: UE 4.10
untitled-2.png (122.8 kB)
more ▼

asked Mar 09 '16 at 09:12 PM in Blueprint Scripting

avatar image

190 35 29 54

avatar image paradoc Mar 10 '16 at 06:06 PM

how is this function or sequence getting called? typically, you would pass in the controller or actor as a parameter into the function so the function knows which object to handle. so for example, if this is a custom event, on your event node, in the details panel, click 'new' and name the parameter 'Player Controller' and set the type to 'Player Controller'. Then when you call this event, you would also pass in the player controller that needs to be impacted by this event. can you post what is triggering this sequence in your graph?

avatar image Anaklosmos Mar 10 '16 at 06:11 PM

These are the two inputs causing this to happen. It is just a simple keystroke or trigger pull.

alt text

woot.png (221.9 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

if you move your input from level blueprint into the player controller blueprint (or character), you will be able to more easily determine who is providing the input to then execute the event on the correct player. here's an example:

Player Controller - create an event dispatcher that includes an input parameter for the controller

Level Blueprint - bind the event to the level blueprint, and call whatever function you want with that event, including the use of the player controller passed into that event. then you can determine if player 1 provided the input or player 2.

controller01.jpg (244.3 kB)
controller02.jpg (244.7 kB)
more ▼

answered Mar 10 '16 at 06:43 PM

avatar image

1.2k 49 31 87

avatar image Anaklosmos Mar 10 '16 at 07:32 PM

My self reference will not hook up into my player controller input on my call event for some reason? And my cast will not accept the controller reference?

alt text

alt text

castfail.png (190.9 kB)
avatar image Anaklosmos Mar 13 '16 at 06:46 AM

Any luck figuring out what I may have done wrong?

avatar image Alex8546 Mar 14 '16 at 02:12 AM

SoocerPlayer is a player character, you need the player controller. You can't cast a player character to a play controller like you're trying to do in the first screenshot. Likewise, you can't cast a player controller to a player character like you're trying to do in the second screenshot.

avatar image Anaklosmos Mar 15 '16 at 12:25 AM

Awesome! I was using a player character without a player controller, so it was not connecting correctly. Thank you both so much for the help! It works perfectly!

(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