User Manual

Legacy Scripting

This is the documentation for the legacy script system. The legacy script system is still available for new and existing projects. When you create a new project you are given the choice over which script system you wish to use.

In general, we recommend you use the new script system. However, there are some use cases where the legacy script system is still required. Use the legacy script system if:

Below is the documentation for the legacy script system

Scripting is how you make your game interactive. Scripts are written in JavaScript. This is the programming language used by web pages everywhere.

You can think of your application as divided into two separate code bases. The Engine, which is provided by PlayCanvas, and implements general purpose functionality such as graphics rendering, input handling, audio, and the interface to the PlayCanvas tools; and Scripts which will often be specific to your application or re-usable chunks that provide useful behaviours.

Generally you won't have to worry about the engine code, it's a single JavaScript file included into your application via a <script> tag. If you're rewriting parts of the engine you probably don't need this introduction to scripting.

Scripts are individual JavaScript files, which are attached to Script Components on Entities via the PlayCanvas Editor. Generally, a script file should define a single JavaScript object which is instantiated once for each Entity that it is attached to.

Note please make sure your scripts are not cached by the browser - otherwise you will not see the results of changes to your scripts. See here.


First off, lets define a few pieces of terminology.