Announcement

Collapse
No announcement yet.

Unreal.js

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [MENTION=47360]kelfire[/MENTION] Calling BP from JS, or JS from BP cannot be optimized by V8.

    Comment


      [MENTION=33973]nako_sung[/MENTION] Is it possible to have 2 custom classes that know each other? In the code below, I created 2 custom actors. The first actor is a sword that has an owner of type myHero. The second actor is myHero with a variable of mySword. If I compile the mySword then myHero, I get this error
      Code:
      Warning: Failed to find object 'Object None.myHero'
      . I can switch the compile order around but I would get this error
      Code:
      Warning: Failed to find object 'Object None.mySword'
      . I know it is possible to write code like that in C++, but is it possible to write a similar code in Javascript?

      Code:
      class mySword extends Actor
      {
          properties()
          {
              this.SwordInt /*EditAnywhere+int*/
              this.myOwner /*EditAnywhere+myHero*/
          }
      
          //overload Event Begin Play
          ReceiveBeginPlay()
          {
      
          }
      
          printMyText() /*BlueprintCallable*/
          {
              //print a text to the screen
              GWorld.PrintText("Sword: Printing Message", true, false, LinearColor.MakeColor(0,0,1,1), 3)
          }    
      }
      
      class myHero extends Actor
      {
          properties()
          {
              this.heroInt /*EditAnywhere+int*/
              this.mySword /*EditAnywhere+mySword*/
          }
      
          //overload Event Begin Play
          ReceiveBeginPlay()
          {
              let sampleSword = new mySword_C(GWorld)
              this.mySword = sampleSword
              //this.mySword.printMyText()
              //this.mySword.myOwner = this
          }
      
          printMyText() /*BlueprintCallable*/
          {
              //print a text to the screen
              GWorld.PrintText("Hero: Printing Message", true, false, LinearColor.MakeColor(0,0,1,1), 3)
          }
      }
      
      let mySword_C = require('uclass')()(global, mySword) 
      //compile myTimeActor
      let myHero_C = require('uclass')()(global, myHero) 
      
      
      //create an actor into the world, can fail if collide at spawn point
      let myActor = new myHero_C(GWorld, Vector.MakeVector(0, 0, 10))
      
      
      //need aliases.js for SetTimerbyFunctionName to be recognized
      Context.RunFile('aliases.js')

      Comment


        Ok, I run the code inside the main function (hotReload_Init) and both custom actors were able to detect each other. The error message is still there, but it works. [MENTION=33973]nako_sung[/MENTION] what is the difference between running the
        Code:
        new myHero_C(GWorld)
        inside the main function instead of outside.

        Code:
        /// <reference path="typings/ue.d.ts">/>
        
        /*
            Description: Create an 2 custom actors that depend on each other
            Detail: Implemented using Unreal Framework
        
        */
        
        class mySword extends Actor
        {
            properties()
            {
                this.SwordInt /*EditAnywhere+int*/
                this.myOwner /*EditAnywhere+myHero*/
            }
        
            //overload Event Begin Play
            ReceiveBeginPlay()
            {
        
            }
        
            printMyText() /*BlueprintCallable*/
            {
                //print a text to the screen
                GWorld.PrintText("Sword: Printing Message", true, false, LinearColor.MakeColor(0,0,1,1), 3)
            }    
        }
        
        class myHero extends Actor
        {
            properties()
            {
                this.heroInt /*EditAnywhere+int*/
                this.myOwnSword /*EditAnywhere+mySword*/
            }
        
            //overload Event Begin Play
            ReceiveBeginPlay()
            {
                let sampleSword = new mySword_C(GWorld)
                this.mySword = sampleSword
                //this.mySword.printMyText()
                //this.mySword.myOwner = this
            }
        
            printMyText() /*BlueprintCallable*/
            {
                //print a text to the screen
                GWorld.PrintText("Hero: Printing Message", true, false, LinearColor.MakeColor(0,0,1,1), 3)
            }
        }
        
        let myHero_C = require('uclass')()(global, myHero) 
        let mySword_C = require('uclass')()(global, mySword) 
        //compile myTimeActor
        
        function hotReload_Init()
        {      
            console.log("zDoubleInherit.js: Initialization")
            new myHero_C(GWorld)
        }
        
        //clean up function for hot reload 
        function hotReload_CleanUp()
        {
            console.log("I am cleanup for live reload")
        }
        
        // 1) bootstrap to initiate live-reloading dev env. 
        try 
        {
            module.exports = () => 
            {
                let cleanup = null
        
                // wait for map to be loaded. then run hotReload_Init() which spawn the MyThirdPerson character
                process.nextTick(() => cleanup = hotReload_Init());
        
                // live-reloadable function should return its cleanup function
                return () => hotReload_CleanUp()
            }
        }
        catch (e) 
        {
            //if try code failed then load required java files
            require('bootstrap')('zDoubleInherit')
        }

        Comment


          *Edit* Nevermind. I can call an Blueprint Interface like any other event/function after doing DoesImplementInterface() check.

          Original
          How do you interact with a Blueprint Interface inside of Javascript? I am able to load a Blueprint Interface using Blueprint.Load() and detect if an Actor is implementing an Interface by using DoesImplementInterface(). I still don't know how to send an interface message to an actor.
          Last edited by kelfire; 09-15-2016, 04:05 PM.

          Comment


            This plugin is very well done;
            There's some wizardry in there I didn't even knew it was possible lol
            | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

            Comment


              Great plugin, but I have one quastion, is it possible to show html page with this plugin?

              Comment


                [MENTION=48942]Legolax[/MENTION] Do you want to show real HTML page? For HTMLs, simply using WebBrowser widget would do the job. If you want to build your own mark up language with HTML tags, you can build HTML renderer which can render HTML to UMG's. (Parsing HTML with some js HTML parser like https://www.npmjs.com/package/htmlparser)

                Comment


                  [MENTION=33973]nako_sung[/MENTION] I`d like to use HTML as Interface, and make js event like "onClick" accessible in blueprint or C++

                  Comment


                    [MENTION=48942]Legolax[/MENTION] HTML is an old day tech. What about angular.js or react.js? There is poc of react.js + unrealengine (React-umg, https://github.com/drywolf/react-umg). Actually I'm doing entire UI coding with umg.js.

                    Comment


                      [MENTION=33973]nako_sung[/MENTION] you are right, but I have the interface like webpage on angular, but how could I connect it to anreal and get event of Onclick and sand some data to this page?

                      Comment


                        [MENTION=48942]Legolax[/MENTION] have you seen react-umg I mentioned above? It might give you a clue.

                        Comment


                          [MENTION=33973]nako_sung[/MENTION], yeah I`ve looked at it, but never used it before, I`ve tried to use an example of react.js connected via unreal.js but no result, it shows me nothing(( I`d like to ask about little help about that, maybe there is another worked little example of that?) Becouse I can`t find a way in wich I can move in this job

                          Comment


                            [MENTION=48942]Legolax[/MENTION] In fact my colleague is working on react-umg and he'll make it as an open source project within weeks. Please stay tuned!

                            Comment


                              [MENTION=33973]nako_sung[/MENTION], thanx a lot for your answers, that was very helpfull
                              I was very glad to discuss it with you

                              Comment


                                Hey [MENTION=33973]nako_sung[/MENTION] -

                                Got a few questions -
                                I am looking at having a custom Node.JS game server integrated into Unreal Engine via Unreal.JS.

                                Would having a game server in Node.JS be advisable? From what I understand as long as I do not do anything "complex" such as physics or whatever I should be good. Is this the case?
                                We are looking at having atleast 100 Players hopefully more on the server at once. Would Unreal JS / NodeJS be able to handle this?


                                Here is the game server we will be using -> http://gamestd.io/colyseus/

                                Just curious,
                                HeadClot

                                Edit: Added the server technology I will be using.
                                Last edited by HeadClot; 09-29-2016, 06:32 AM.

                                Comment

                                Working...
                                X