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 enable input for only specific characters?

Hey all,

I was wondering if there is any way to assign specific actions only to specific characters.

For instance, I have an Action Mapping ("Interact") that only one of the three characters in my game should be able to use. In this case, "Interact" happens when the M key is pressed.

I'm creating a single-player game where the player can assume control over any of the three characters in the game by respectively pressing the 1/2/3 key.
What happens now is that no matter which character the player has possession over, once the M key is pressed "Interact" always happens. So in this case, only character nr. 2 should be able to perform "Interact".

Any help is appreciated :)

Product Version: UE 4.10
Tags:
more ▼

asked Jul 18 '16 at 02:12 PM in Blueprint Scripting

avatar image

Stradis
50 17 17 19

avatar image mdmoberly Jul 18 '16 at 02:17 PM

Hello, Stradis!

In which BP are you possessing the other characters? Are you doing that on your level BP?

avatar image Stradis Jul 18 '16 at 02:19 PM

Hi again!

Yes, in the level BP. Here is a screenshot:

alt text

levelbp_possess.jpg (161.0 kB)
avatar image _eni Jul 18 '16 at 04:01 PM

Create a Boolean variable for Character 2, name it however you want ie: (isPossessingC2). Then connect it to all 3 Possess parts for each character in the player select part of your levelBP using "Get isPossessingC2". Then

  • For input 1, the variable is set to False

  • For input 2, the variable is set to True

  • For input 3, the variable is set to False

Now create a Branch where your Interact stuff is at (Perhaps before the Character Range Branch) and the condition is that Boolean variable you created.

  • On True, connect it to what you are doing (the FlipFlop or whatever you are doing)

  • On False, do nothing (leave it alone)

Now, only when you press 2 and switch to character number 2, you are able to do the interact input action.

avatar image Stradis Jul 18 '16 at 04:05 PM

That did the trick. Thank you!

avatar image mdmoberly Jul 18 '16 at 02:52 PM

And where are you executing you "Interact" logic? Are you doing that on your Level BP as well?

avatar image Stradis Jul 18 '16 at 03:02 PM

Yes, that is also in the level BP. Just in case it's of any help, I'll add screenshots of that as well so you can see how it gets executed:

alt text alt text

bbb_blueprint.jpg (326.1 kB)
kh_blueprint.jpg (325.4 kB)
kh_blueprint.jpg (325.4 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Since I cannot mark comments as accepted answers, for administrative purposes I will put this comment and mark thread as solved. For future answer-seekers, see comments below for the suggestions that have been given!

more ▼

answered Jul 18 '16 at 04:15 PM

avatar image

Stradis
50 17 17 19

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

There is! I assume each character has different interaction logic they will execute? You can use a Enumeration system.. Create a new Enum BP called Possessed Character. Create three options (one for every character that will be possessed). In your Level BP create a new variable that is that Enum BP. Now you want to set the enum variable after you Possession logic (keys 1, 2 and 3). Now you will want to "Switch on Enum" after you "Interact" key event.

This will work somewhat like a boolean.. when interact is called, it will look at the enum and see which character is selected and then only execute that logic.

If you're interested in getting it set up the way I suggested previously, let me know and I can help you get there!

Hope this helps! Matt

more ▼

answered Jul 18 '16 at 03:43 PM

avatar image

mdmoberly
205 13 25 27

avatar image Stradis Jul 18 '16 at 04:11 PM

Hey! I tried the Enum BP approach, probably did something wrong because it didn't work as I expected it to. But actually I found a solution through another user that worked for me, at least it works for what I'm creating. Although I realize my entire blueprint logic in this case might be a bit unorthodox :)

Thanks a lot anyway, you always introduce me to new features in Unreal so that is great!

avatar image mdmoberly Jul 18 '16 at 04:29 PM

You're most welcome!

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

You should execute your "interact" logic on your Character BPs. That way you are only calling Interact for the character that you have possessed.

more ▼

answered Jul 18 '16 at 03:18 PM

avatar image

mdmoberly
205 13 25 27

avatar image mdmoberly Jul 18 '16 at 03:26 PM

If you're free around 530 central time, I can help you with this bit. You're going to need to move some stuff around to get this to work the way you want.

If you don't want to move this bit, there are a few other things you can do on your Level BP like setting up Booleans to make your Interact logic character specific.

avatar image Stradis Jul 18 '16 at 03:28 PM

I was afraid that might be the only solution, but that really makes things complicated for me since I have no idea how to successfully use casting and create references in character BPs. It would be really handy if the interact logic could remain in the level BP.

I assume there is no workaround for this?

avatar image Stradis Jul 18 '16 at 03:31 PM

Oh nevermind my previous comment then! Yes I think using Booleans might be a more suitable solution in this case.

I am free around that time. That would be in around 7 hours, correct? (I live in The Netherlands)

(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