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”.
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.
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.
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!
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.
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!
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!