Importing/Using regular javascripts within playcanvas entity javascript

This should be very simple to do but i cant find the way to do it :stuck_out_tongue_winking_eye:
I am trying to use a ‘regular’ javascript library called finite-state-machine
(https://github.com/jakesgordon/javascript-state-machine)

  1. I downloaded the javscript file on my script project folder
  2. On the play canvas entity code I use:
    var engine = pc.createScript(‘animation’);
    engine.attributes.add(‘stateMachine’, { type: ‘asset’, assetType: ‘script’, array: false });
  3. Drag and drop the assigned script as a parameter of engine.

var StateMachine = self.stateMachine.resource;
self.stateMachineApplication = StateMachine.create({

I also notice that external javascripts not formated as an entity script are not recognized…

A tutorial should be nice as this stuff should be basic and no expect the developer to port stuff into playcanvas style scripts. thanks

To include a JS file that is not an entity script you just need to add it to your assets for the project. It will be loaded as a regular javascript file. No changes are needed.

If you need to make sure it is loaded before other files, you can adjust the loading order in the Loading Order section of the scene settings: http://developer.playcanvas.com/en/user-manual/scripting/loading-order/

I’ll update the manual to include a section on including regular JS files.