Unreal.js

I don’t know if this is the right place to ask, but…
If you extended a class such as BTTask or BTNode (for the AI system), would you be able to access that from within the behavior tree editor just as you would with a C++ or Blueprint class? Or is extending classes solely for the purpose of being able to create them within JS?

EDIT: I think I’ve just figured it out. Once you call compile(class) or require(‘class’)()(global, class) on your class, it becomes loaded into the UE4 reflection system as a proxy object (I’m guessing), therefore becomes usable?

#Unreal.js demo is available! :slight_smile:

https://github.com/ncsoft/Unreal.js/releases/download/snippet-editor/JavascriptSnippetEditorSample.zip

Yes. JS generated class is fully accessible by other BP’s and C++ classes, but they cannot link/refer to generated class directly. :slight_smile:

nako_sung: “In JS, you can access any actors which are already spawned in your world.”.

  1. That is, as i understand, I need to create some Actor like Cube and place in scene. Then somehow i need put my widget inside this Actor (to variable) and then through GetAllActors i get this variable and intercat with it. I understand correctly?

  2. If yes, i need create some LogicActor and put to them all UMG widgets to access them from JS.

  1. Widget can be created within JS.
    GWorld.CreateWidget(WidgetClass, GWorld.GetPlayerController(0))

1-1. You can define your widget in JS. (please refer to .js)
1-2. You can use your UMG BP. GWorld.CreateWidget(Blueprint.Load(your-umg-path).GeneratedClass,…)

:slight_smile:

1-2 what i need. I try and its working. Thank you.

I install Node.js Tools for VS 2015. Qualifier: localhost:5858. Script open in VS is helloBlueprint.js (drag and drop to IDE, not project setup). But in Available Process is nothing, when click to Refresh AttachToProcess write error Make sure that the process is running. Help please.

What books you are using for writing this plugin? How you start your work. With which began its work? Interesting how creating this projects…

You can attach debug enabled javascript context marked with Context.SetAsDebugContext ().

In fact I don’t have any programming language books. I usually love googling!

If I’m not tired yet you…

  1. my logic of level is:
    Actor walk and overlap trigger, then i press E key and creating Widget. When i press button in Widget i calculate some math logic. I try put this logic inside JS.

If i creating (init) this Widget inside JS, my Blueprint (press E, overlap) breaking… How can i embed UnrealJS in this logic without breaking created Blueprint?

I need synth Blueprint and UnrealJS…

  1. When i creating process for debugging, all work fine. I start level inside UE, than attach to process… but how can i debug for example Main function variables (when i start unreal Main is already calling and i can not debug)?
  1. All you want is just calculating something. You can define a placeholder Blueprint class which has several overridable functions. And then in JS you can extend that class to override functions, and let your BP know ‘new JS generated class’.

  2. You can add some function to wait until debugger attached by placing some Widget or timer (setTimeout(main,5000)).

Thank you very mush.

I have a function and i need put to input arrays of bools what syntax is using?

math_JS(arr/array/) /NetMulticast/ {
console.log(arr[0], arr[1], arr[2])

not working

syntax is like below; (referring to Unreal.js/helloBlueprint.js at master · ncsoft/Unreal.js · GitHub)

this.Hello/Replicated+EditAnywhere+int/;
this.Position/EditAnywhere+Vector]/;

So, you can write

math_JS(arr/Bool]/) {
}

No /Bool]/ is not working… if i put Int=0 is all fine (print 0), but when i put Array from Blueprint is print Undefined.

note: in blueprint i creating node MakeArray and put Boolean=false to first Pin. MakeArray output connect to input of math_JS…

What to do?

Have you tried with other types like float, string, …? Unfortunately, I cannot test with PC for right now. (I’m out of the office this week)

Int and bool as input types work correctly other not tested (array not working). And one thing:

I creating math_JS and override them, in JS return true, but Blueprint function always return false.

Abstract examle:

*math_JS() {
return true
} *

Blueprint function return always false, if i try return int return always = 0. May be i do something wrong?

What your source code responds for this?

If your return param doesn’t work, please try with return {$:true}.

return {$:true} - not working… function always return false

If i manually return for example True and delete function inside JS code… all work fine, but when function is override by JS return not working.

For a workaround, you can define a member variable in your BP which hold return value. In js function, js function writes return param value into that property. :slight_smile:

That’s exactly what I did :cool:

Will correct errors?