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"

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 :-/alt textalt text

Product Version: UE 4.21
Tags:
more ▼

asked Jan 08 '19 at 10:44 AM in Blueprint Scripting

avatar image

Ja_jujo
5 1 3

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.

Creating a new event dispatcher

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

Calling event dispatcher

  • 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 ++).

Setting up the binding to the event Creating an event which calls the code to be executed

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

Running the code

capture0.png (4.7 kB)
capture3.png (54.1 kB)
capture4.png (178.4 kB)
capture5.png (59.2 kB)
capture6.png (147.6 kB)
more ▼

answered Jan 09 '19 at 02:24 PM

avatar image

Weibye
190 1 6 5

avatar image Ja_jujo 6 days ago

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 :) and will let you know about my progress! Again thanks a lot for your detailed input :)

avatar image Weibye 5 days ago

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

(comments are locked)
10|2000 characters needed characters left
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