Skip to main content

Scripting Fundamentals

Master the core concepts of PlayCanvas scripting. Whether you're using modern ESM scripts or classic scripts, these fundamentals apply to all PlayCanvas development.

Essential Concepts

Getting Started

Learn the basic structure and syntax of PlayCanvas scripts. Understand how scripts work, their lifecycle, and how to attach them to entities.

ESM Scripts

Explore modern ES Module-based scripting with classes, imports, and better tooling. Recommended for new projects.

Script Lifecycle

Understand when and how script methods are called - from initialization through updates to cleanup.

Script Attributes

Expose configurable properties that can be tweaked in the editor or set programmatically.

Calling the Engine API

Learn the key PlayCanvas Engine classes and patterns you'll use when writing scripts.

Events

Learn how scripts communicate with each other and respond to changes in your application.