Announcement

Collapse
No announcement yet.

[RELEASED] Flathead = UE4 + Javascript

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

    [RELEASED] Flathead = UE4 + Javascript

    Overview

    The first thing I ran into as a problem within the technical side of developing on the unreal platform, years ago, was the compile times. UnrealScript was occasionally a hand full of seconds long, but on larger projects it would balloon tremendously. Now that we have graduated to UE4 compile times are still much longer than simply saving files out. I am a firm believer in the benefits of working with scripting languages being bound to platforms, and have undertaken linking V8 into UE4 here. I will be documenting the capabilities in the change log that follows.

    Please send me questions or comments directly, as if we rely upon forum notifications things may get past me. I will likely have an alpha together for people to test in the next few days.

    Download | Wiki | Trello

    Change Log

    Unreleased

    • Updated to V8 v.3.29.58


    Alfa Romeo - 1.0.0 - 05/26/2014
    • Exposing of variables as properties and using accessors is now working
    • Most of the UE4 float/double math library is exposed.
    • Started exposing UObject basics.


    RC1 - 03/29/2014
    • Repurposed as Plugin. It is now fully self contained.
    • Executing Raw JS code from any point after the module StartModule method is functional. The plugin loads before game modules do.
    • addEventListener, CustomEvent dispatchEvent are now defined.
    • Load method added to API.
    • V8 is linked into UE4 via a module
    • Added a game object, which has a function for each level of UE4 logging as well as a property for the version of the game, defined in a constant.
    • Added a v8 object, providing a property to query the version of the binding, incremented as the API evolves, and a property to query the version of v8 included in the binding.
    • Loading of scripts based in the modules Source/JS directory from the console as well as from module loading.
    • String Conversion between V8 and UE4.
    • Exposing static methods in the form of an object


    &tldr;

    I have linked V8 JavaScript into UE4 and am tuning it to purr like a kitten.
    You may download immediately.

    Last edited by Bob_Gneu; 09-16-2014, 02:31 AM. Reason: Updating with release details
    About Me | JavaScript and UE4 | Exodus | Code Notes

    #2
    This is cool! Nice work!

    I'm curious, what could this integration be used for?

    Cheers,
    Jon
    Q.U.B.E. 2 | Q.U.B.E: Director's Cut

    Comment


      #3
      I have an old Beta build, but I have already bound it into my world generation routine and handled the actual algorithm and creating of entities in the world entirely in JS. Now that we have full source access it can be extended to provide a callback to any C/C++ static or member function that can then call into any other part of the world. Its actually quite flexible and the API is up to us. I actually handled the eventing logic in JS land, creating the objects and what not in JS instead of having to create and validate all of the objects needed in C++, and it works swimmingly.

      The only thing I am not entirely comfortable with is how to handle is references to assets, but that will come in due time, probably via a JS constructor call or something.

      Cheers =)
      About Me | JavaScript and UE4 | Exodus | Code Notes

      Comment


        #4
        Great project, manipulation through JS could be very handy for those coming from that realm.

        Comment


          #5
          I think that's about the way it will work out. JS has a tendency to get messy pretty quick, but i think with some diligence on my part I may be able to sort that out. Its very interesting to be working with the full version of JS and not the subset that is available in Unity. I think tonight or tomorrow I may have some more time to get something useful together for you guys to see things working.

          For now, I am waiting on the update to UE4 and revising my code.
          About Me | JavaScript and UE4 | Exodus | Code Notes

          Comment


            #6
            This is an amazing project Bob!

            Great work and very creative thinking on your part!

            Rama
            100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

            Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

            Comment


              #7
              I agree, this would be a great addition.

              Comment


                #8
                I'm really looking forward to V8 integration, I had hoped this would happen, as I've got quite a chunk of AI/procedural code written in JS. Also, I'm currently teaching my 10-year-old nephew to program in JavaScript (in minecraft), this could act as a nice stepping stone.

                Good luck!

                Comment


                  #9
                  I just finished sorting out the linking and resource notes for a plugin and V8 is now a togglable plugin in the UE4 Editor Plugins menu.
                  About Me | JavaScript and UE4 | Exodus | Code Notes

                  Comment


                    #10
                    Would be nice to create server side, hot reload scripting.

                    Consider for example UOX (Ultima Online Emulator):
                    http://sourceforge.net/projects/uox3...0JS%20Scripts/

                    Comment


                      #11
                      Officially posting my interest in this. Still quite new to the engine, and blueprint seems nice, but I do think there is a place for a scripting language with access to the same behaviors.

                      Am curious what the API would be like. Unity implements a strange class system (using a made up keyword) that automatically inherits from MonoBehavior (their basic class which can overrid Update - their tick method). To dump a behavior on an object, they have you drag a reference to the source onto the object in world, which creates a monobehavior component.

                      In UE, we have a blueprint object, which has a parent, and can access components on itself or the level trigger events, and so on. In C++ land, you have the same thing, but add your components via code in the constructor, like so:

                      Code:
                      SphereTrigger = PCIP.CreateDefaultSubobject<USphereComponent>(this, "SphereTrigger");
                      I wonder if on the js side, you could inherit using prototype chains and something like util.inherits from node.
                      Docs: http://nodejs.org/docs/latest/api/ut...perconstructor
                      Source: https://github.com/joyent/node/blob/...l.js#L618-L641 - it ends up being some very small boilerplate for setting up prototype chains

                      Resulting in something like:

                      Code:
                      function MyActor() {
                          UE4.AActor.call(this);
                      
                          PCIP.CreateDefaultSubcomponent(UE4.USphereComponent, this, "SphereComponent");
                      }
                      
                      util.inherits(MyActor, UE4.AActor);
                      Basically, mimicking the C++ API. Maybe too difficult to get it to behave the same, but just a thought. Could also use decorators or some sort of API to expose variables to the defaults editor so that you could extend a js "class" -- p.s., don't tell any javascript programmer that I used the word class. They'd **** in their pants.

                      Comment


                        #12
                        I could see this also being highly useful for prototyping as a middle-ground (and actually due to the planned features an addition to) Blueprints and pure C++. I'd definitely be interested in helping maintain it when you decide to open it up.

                        Keep up the good work.

                        Comment


                          #13
                          Issues now on public Trello

                          I have moved the Hurdles to Trello. Hopefully that will give you all more visibility into what I am currently working on so things are clear.

                          I am broken up about whether to allow comments or not, but for now they are open. Please be patient and follow Notch's advice.

                          You can now vote & comment on issues to help me better prioritize my tasks to meet your demands.

                          Current Goal: Define a set of BP nodes that would be useful.

                          To Be Included in initial Release
                          1. Load & Execute JS by fileName
                          2. Execute Raw JS from text field or variable
                          2. Retrieve value of object
                          Last edited by Bob_Gneu; 03-26-2014, 01:58 PM.
                          About Me | JavaScript and UE4 | Exodus | Code Notes

                          Comment


                            #14
                            Pardon my ignorance on the subject, but if this is V8 running inside UE, then could we not also extend that to include running other things that run on top of V8 like node or mongo. Just the thought of having a node server that would be able to interact with UE on this level has my head spinning with ideas!

                            Comment


                              #15
                              You wouldn't run another app on top of this, really. Mongo has c bindings, and Node does as well. This binding that I am putting together is really going to be focused on exposing, creating and interacting with game components.

                              The good news for you is that you can still interact across applications using TCP and UDP communication, as well as any sort of bindings you choose to spin up, like mongoDB managers or hell, you could put a web server together too if you so chose. There are a number of opportunities available to you. I can help you with at least getting a bearing if you are so inclined.
                              About Me | JavaScript and UE4 | Exodus | Code Notes

                              Comment

                              Working...
                              X