Hey Devs,
I made a new experimental open source (MIT) plugin that embeds Node.js scripts as an actor component. Currently super early, but usable so wanted to share. Will likely have some bugs this early on, if you find any, post to Issues · getnamo/nodejs-ue4 · GitHub.
You can now write any node.js script and use npm modules to solve problems. The node instance is fully embedded, no external installation required.
Main repository and documentation:
Latest release:
Basic how-to
e.g. a simple math function using the npm package *ipc-event-emitter *to listen and reply with events
//myscript.js - Let's connect our 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');
And on the blueprint side, add a node component
https://i.imgur.com/Xvc6v98.png
set your script
https://i.imgur.com/xalQplZ.png
and bind to the event you used in your script and you can call your script function to e.g. get the Pythagorean distance of two floats
https://i.imgur.com/XVe64kA.png
The scripts run on background threads and will not block the game thread. Messaging does callback on game thread so bound events are safe to use as usual.
That example is obviously just bare bones and not particularly useful, but you can change your script to use any NPM module (https://www.npmjs.com/) which has tons and tons of cool solutions to common programming problems.
See this list for some ideas: https://github.com/getnamo/nodejs-ue…you-do-with-it
Isn’t this just unreal.js?
Unreal.js is much much cooler and definitely better suited if you want to control unreal engine with javascript. This plugin instead focuses on bringing support for node.js API and full npm compatibility. You can probably use both together if you like.
Limitations
Win64 only for current builds.