Globally trigger event in Blueprint by Keyboard (VR)
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 :-/
asked Jan 08 '19 at 10:44 AM in Blueprint Scripting
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here