Globally trigger event in Blueprint by Keyboard (VR)

Hi everyone,

I am currently working on a BP that lets the player cycle through several static meshes I store in an array. I use this for a VR experience where my client can review several versions of a design. So far the BP works as intended - the player can approach the object in VR and while touching it he can switch to the next item in the array by pressing a button on the Oculus Rift Motion Controller. I am doing this by controlling the current mesh with an integer that will always be incremented +1 and in the end loop back to index 0 of the array. This blueprint is then placed three times in the level, each BP is “filled” with different Meshes (e.g. BP instance 1 has 6 different cars, BP instance 2 has 6 different chairs and so on) So far so good.
Now I want the possibility to globally switch all three BP to show a certain item by pressing a keyboard key (e.g. I press “2” on the Keyboard and all BP instances show the item that is stored in the corresponding index of the array).
This however does not seem to work properly as it only works as long as the player still touches a BP mesh and then it only works for that specific BP. It seems I have to “globally” activate the keyboard commands with a “Get Player Control” but I also don’t want to break the teleport locomotion (if the player is not touching a BP Object he/she can teleport - I am using the Unreal VR template for player control). First picture shows the part of the BP that controls the mesh swap second picture shows the global switch - what am I missing :-/

Event dispatchers are excellent for these type of things, though can be a bit tricky to get your head around if you haven’t dealt with them before. Essentially you can have one main ‘trigger’ that calls anything, anywhere, that has been bound to it. In you case, you can create an Event Dispatcher in your VR Pawn and bind the events in the mesh-blueprints to that so that they all trigger whenever you trigger that event dispatcher.

  • In VR Pawn: Create a new Event Dispatcher. You can add inputs just like with any other function call.

264709-capture0.png

  • In VR Pawn: call the even dispatcher by using a keyboard input or whatever else suits your needs.

  • In your Mesh Blueprint: On begin play, get a reference of the VR Pawn, then bind the event dispatcher to a new event.
  • In your Mesh Blueprint: Create a new event that performs the code you need to take place (change mesh value ++).

  • Placing 5 instances of that blueprint in the level and pressing O when game has started gets this result:

264725-capture6.png

Wow thanks a million for that answer - I am away from my computer but I’ll test it first thing in the morning. to be brutally honest I resolved my issue earlier today by and did not update this post yet - I will test out that solution anyway to learn more about event dispatchers :slight_smile: and will let you know about my progress!
Again thanks a lot for your detailed input :slight_smile:

Not to worry. Event Dispatchers are just another tool in your tool-set that can be very powerful when used properly.