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"

Dispatching custom blueprint events via Javascript

I'm currently trying to find a way to make the custom blueprint events (or delegates from c++) visible to javascript.

After exporting I want to be able to make a call for these event, something similar to request_fullscreen_callback from HTML5OpenGL.cpp, but I could not solve how to bind the blueprint class to emscripten.

I tried to embind c++ classes without success. Default C++ classes are ok, blueprint classes, I have no idea how to accomplish.

Here is a case to make the question a little more understandable: Let's say that there is a point light in the scene and a button inside a widget. When a user releases the button, an event fires. On blueprint, the event is assigned and point light is turned on or off.

I want to replace the widget button, and instead use an HTML dom object instead. So when user releases the dom object, I want to trigger the same (or something like that) event to turn the point light on or off.

Is there any examples in UE4 code that I can check? Is this possible?

Product Version: UE 4.9
Tags:
more ▼

asked Oct 09 '15 at 12:18 PM in C++ Programming

avatar image

emrahgunduz
168 13 15 21

avatar image emrahgunduz Nov 06 '15 at 05:16 PM

I've solved this by trying to simplify the problem. I wrote a blueprintable C++ class that calls a JS function on each tick and checks if any messages (JS array with json data) is waiting, receives any waiting data and acts accordingly (populates data on UE4 side, calls delegate, etc). It works very well and does not crash the speed of the game or system. If anyone needs something similar, just ask here :)

avatar image generallyjansen Mar 25 '16 at 10:32 PM

Hi there, I believe I'm trying to accomplish something similar (based on your description). What did you have to configure in order to get your game to call Javascript from the C++ classes?

In context, I'm building a game to export to HTML5 and I want to make some calls to the browser's api, but I'm just now looking at how that might work. Any guidance that you can give would be very helpful. Thanks!

avatar image emrahgunduz Mar 28 '16 at 09:38 AM

you can use emscripten's methods for calling js methods ( c++ >> js calls ). check this url out for details. Check out the emscripten_run_script parts. You can send a stringified json to js part, parse the string and use as data.

js >> c++ part is a little hard to incorporate if you are not compiling ue4 by yourself. you'll need to add a few modules to emcc by yourself. but there is also a simpler solution.

  • write a notification / message system on js side that fills an array with whatever you want (maybe json objects, something like { action: "do-something", data: { ... } } )

  • write a blueprintable c++ source that calls the methods of the notification system with "emscripten_run_script" to check if a message is waiting, or to get the next message.

  • from blueprint use these methods and on each tick ask for a message (blueprint can ask for a specific action marked message and receive it, by this way every blueprint can tick for messages), then do whatever you want to do.

this will solve the problem and does not cause any slowness on html5 part. every blueprint can ask for a specific type of message, and receive the answer.

it seems hard to accomplish, but it simply depends on your js knowledge at this point. c++ and blueprint part are easy.

check https://github.com/ufna/VaRest if you do not know how to work with json + ue4 on c++ part.

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

0 answers: sort voted first
Be the first one to answer this question
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