All Projects → getnamo → Nodejs Ue4

getnamo / Nodejs Ue4

Licence: mit
Embed node.js as an unreal plugin.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Nodejs Ue4

Unrealclr
Unreal Engine 4 .NET 5 integration
Stars: ✭ 1,275 (+1454.88%)
Mutual labels:  unreal-engine-4, plugin
Ue4voxelterrain
[WIP] Unreal Engine 4: Smooth voxel terrian example
Stars: ✭ 415 (+406.1%)
Mutual labels:  unreal-engine-4, plugin
Fworldgenerator
Procedural world generator (plugin) for Unreal Engine 4
Stars: ✭ 45 (-45.12%)
Mutual labels:  unreal-engine-4, plugin
Homebridge Weather
OpenWeatherMap Plugin for Homebridge
Stars: ✭ 78 (-4.88%)
Mutual labels:  plugin
Httpie Oauth
OAuth plugin for HTTPie
Stars: ✭ 78 (-4.88%)
Mutual labels:  plugin
Xcodecolorsense
🎈 An Xcode plugin that makes working with color easier
Stars: ✭ 79 (-3.66%)
Mutual labels:  plugin
Sentinl
Kibana Alert & Report App for Elasticsearch
Stars: ✭ 1,233 (+1403.66%)
Mutual labels:  plugin
Bgworker
Background Worker Processes for PostgreSQL written in Go
Stars: ✭ 77 (-6.1%)
Mutual labels:  plugin
Tensorboard Empty Scalar Hider
Chrome Extension of hiding empty scalar/panes in TensorBoard.
Stars: ✭ 81 (-1.22%)
Mutual labels:  plugin
Ue4linuxlauncher
Stars: ✭ 79 (-3.66%)
Mutual labels:  unreal-engine-4
Pluginapplication
学习Android插件化必备demo
Stars: ✭ 79 (-3.66%)
Mutual labels:  plugin
Comet Cache
An advanced WordPress® caching plugin inspired by simplicity.
Stars: ✭ 78 (-4.88%)
Mutual labels:  plugin
Craft Async Queue
Async Queue Handler for Craft 3
Stars: ✭ 80 (-2.44%)
Mutual labels:  plugin
Summernote Image Attributes
Summernote plugin to edit image attributes
Stars: ✭ 78 (-4.88%)
Mutual labels:  plugin
Obs Gnome Screencast
GNOME Screen Cast OBS Studio plugin
Stars: ✭ 80 (-2.44%)
Mutual labels:  plugin
Kibananestedsupportplugin
A plugin for Kibana 5.5 and beyond that adds support for nested field search and aggregation.
Stars: ✭ 78 (-4.88%)
Mutual labels:  plugin
Hidden Secrets Gradle Plugin
🔒 Deeply hide secrets on Android
Stars: ✭ 79 (-3.66%)
Mutual labels:  plugin
Awesome Typescript Ecosystem
😎 A list of awesome TypeScript transformers, plugins, handbooks, etc
Stars: ✭ 79 (-3.66%)
Mutual labels:  plugin
Splashpublishplugin
A Splash plugin for the Publish static site generator
Stars: ✭ 79 (-3.66%)
Mutual labels:  plugin
Vue Rawmodel
RawModel.js plugin for Vue.js v2. Form validation has never been easier!
Stars: ✭ 79 (-3.66%)
Mutual labels:  plugin

nodejs-ue4

Embed node.js as an unreal plugin. This enables you to embed cool things like: https://www.npmjs.com/.

GitHub release Github All Releases

Want to control unreal with javascript? consider using https://github.com/ncsoft/Unreal.js which is much more feature-rich. This plugin instead focuses on bringing node.js and npm api on background threads.

Currently in an early working state, may have bugs!

Novelty example controlling boxes using javascript with live reload in an async loop which shows upward of ~20k messages/sec not impacting game thread.

Questions and Feedback

Got questions or problems? post to https://github.com/getnamo/nodejs-ue4/issues

or discuss in the Unreal forum thread

What can you do with it?

A lot of really useful programming solutions exist for node.js; all the npm modules can now be used with unreal. A small sample of possibilities:

Communications

Great native support for http and embedding simple servers. You could for example run a local embedded webserver and serve that webpage as a UI using e.g. https://github.com/getnamo/BLUI

Math

Commandline

You can e.g. embed any other bat or commandline executable and parse args to control

Utilities

And much much more:

Quick Install & Setup

Via Github Releases

  1. Download Latest Release
  2. Create new or choose project.
  3. Browse to your project folder (typically found at Documents/Unreal Project/{Your Project Root})
  4. Copy Plugins folder into your Project root.
  5. Plugin should be now ready to use.

How to use - Basics

Early example project

See NodeJSExampleProject-v0.4.2.7z in https://github.com/getnamo/nodejs-ue4/releases/tag/0.4.2 for a drag and drop example project.

Blueprint side

Add a Node Component to actor of choice

add component

In your component properties set the name of the script you wish to run e.g. myscript.js. This path is relative to {Your Project Root}/Content/Scripts/.

set script

Command line arguments

Command line arguments are supported, just add them to the script path, separated by "|". Arguments which contain spaces should be enclosed in double quotes. Example:

myscript.js|--parameter=value "--parameter-with-spaces=value with spaces"

Now let's look at a basic script

Node Scripts

Place your script files inside {Project Root}/Content/Scripts

The script files can be vanilla javascript, node.js, and/or include npm modules (since v0.2 ensure you add them to your folder's package.json to auto-resolve on run).

A basic example with just console.log output

//1) simple basics work: Just log stuff!
const euclidean = (a, b) =>{
	return ((a ** 2) + (b ** 2)) ** 0.5;
}

a = 3;
b = 4;
c = euclidean(a,b);

console.log('(a^2+b^2)^0.5: ' + c);

To listen to your script log bind to the node component event On Console Log

on console log

but what if you want to send data/receive data to your script?

A basic adder

Let's expand the script to include the npm module ipc-event-emitter. We will use this to communicate events back and forth to our blueprint component

//2) Let's connect our euclidean function via IPC

//One liner include
const ipc = require('ipc-event-emitter').default(process);

const euclidean = (a, b) =>{
	return ((a ** 2) + (b ** 2)) ** 0.5;
}

//Listen to 'myevent' event
ipc.on('myevent', (vars) => {
	let c = euclidean(vars.x, vars.y);
	console.log('Got a request (a^2+b^2)^0.5: ' + c);

	//emit result back as a 'result' event
	ipc.emit('result', c);
});

console.log('started');

On the blueprint side, our scripts start on begin play (a toggleable property on the node component) and has an event called OnScriptBegin. We use that event to bind to the result event first and then emit a vector2d with x and y float values and convert it to a SIOJsonValue, this will autoconvert to a json object in your script side.

bp comms

When the script emits the result event, it will return to our component OnEvent event (you can also bind directly to a function see https://github.com/getnamo/socketio-client-ue4#binding-events-to-functions for example syntax). In the example above we simply re-encode the message to json and print to string.

That's the basics! There are some other events and functions for e.g. starting/stopping and getting notifications of those states, but largely anything else will be in your node.js script side.

Packaging

Works since v0.5, just make sure to add the folder where your project Scripts are as additional non-asset directories to copy relative to the Content directory (e.g. for the typical Content/Scripts folder add just Scripts)

Usage Notes

Errors

If you write an error in your script, it will spit it out in your output log. Hitting save and re-running the component will re-run the script.

error

npm modules

Since v0.2 script errors caused by missing npm modules will auto-check the package.json in your script folder for missing modules. If the dependency isn't listed it will warn you about it, if it does exist it will auto-resolve the dependencies and re-run your script after installation; auto-fixing your error.

Basically keep your script's package.json up to date with the required dependencies and it will auto-install them as needed without performance implications (doesn't check every run, only on script error).

properties

You can disable this auto-resolving and auto-run on npm install via the node component properties. Then you can resolve Npm dependencies at your own time with the node component function Resolve Npm Dependencies.

resolve npm manually

Multiple scripts

Works, just add another component and all action for a script will be filtered to only communicate to the component that launched it.

Using git instead of releases

This is supported, just download https://github.com/getnamo/nodejs-ue4/releases/download/0.5.0/nodejs-v0.5.0git-thirdparty-dependencies-only.7z in https://github.com/getnamo/nodejs-ue4/releases/tag/0.5.0 release and extract it into your project root (where the plugins folder is). This will add dependencies that are missing if you pulled a fresh clone from git.

Limitations

Current builds are Win64 only.

Communication to embeded node.exe takes place internally via socket.io protocol with tcp. Comms and scripts run on background threads with callbacks on game thread (one subprocess for each script). This means nothing blocks while the scripts run, but sub-tick communcation latency is not possible as each message roundtrip will take at least one game tick. e.g. sending a message to your script on this tick will usually result in a callback on next tick.

Very large bandwidth may become an issue (e.g. feeding image data each tick), but hasn't been tested and there are some optimizations that can be used.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].