Skip to content
On this page


Components have scripts attached to them that are responsible for prviding the logic for the behaviour. There are 2 types of scripts

  • Game Scripts responsible for game logic. Bundled with the game.
  • Editor Scripts responsible for inEditor beahaviour. These are not bundled with the game.

This section will cover Game Scripts.

To update scripts ensure that the scripts section is visible. enable scripts section

Each script has an event associated with it. The script file must export a function with the same name as the event. This function is triggered on the event. event name for script

Example script

// initScript.ts

import type { Callback, InitEvent } from '@thejsngin/jsngin';

const init: Callback<InitEvent> = (gameInstance, gameObjectInstance, componentHelpers) => {
    console.log('init triggered')

export { init };

Add this script to any component with init as the event name. custom init script

On running the game with npm run dev you should see the "init triggered" appear in the console.


All the default events can be found here