Menu
Amazon Sumerian
User Guide

Scripting

Add scripts to your scene to update your scene based on user input or events. You can use scripts to access the DOM, create and modify entities with the Sumerian engine library, or use the AWS SDK for JavaScript to access AWS services and resources.

Note

Visit this guide's GitHub repo for a collection of useful sample scripts. Contributions are welcome!

To create a blank script

  1. Open a scene in the Sumerian editor.

  2. Create a blank asset by clicking the plus icon next to the default pack and then click Script. Select the pack name to see the icon.

  3. Press j to open the text editor.

  4. Choose the new script under documents. Use the pencil icon next to the script name to change its name.

The script template includes 7 methods and a parameters array. The methods correspond to a scene's lifecycle events and are called by the engine at the following times.

  • setup – When scene playback starts.

  • fixedUpdate – On every physics update.

  • update – On every render frame.

  • lateUpdate – After calling all update methods in the scene.

  • enter – On a state machine script action, when the state is entered.

  • exit – On a state machine script action, when the state is exited.

  • cleanup – When scene playback stops.

Reference documentation for the Sumerian engine library is available on the Sumerian website.