Guides Behaviours What Is a Behaviour?

Behaviours 2 min read Updated Apr 2026

What Is a Behaviour?

A `Behaviour` is a PHP class attached to a GameObject as a component.

Use a Behaviour when code needs to participate in the scene: object ownership, lifecycle methods, Inspector fields, or coordination with other components.

Use regular PHP classes, enums, and utility code for logic that does not need to live on a GameObject.

What a Behaviour Does

A Behaviour can:

  • read input
  • move or rotate a GameObject
  • talk to other components
  • respond to collisions
  • start coroutines
  • emit gameplay events
  • expose fields in the Inspector
  • run code every frame

It is still a component, but it is one you write for scene-attached gameplay.

How Behaviours Relate to GameObjects

A Behaviour does not float around by itself.

It belongs to a GameObject. When the GameObject is active and the Behaviour is enabled, Lenga can call the Behaviour's lifecycle methods.

That relationship gives the Behaviour access to the object it controls.

A typical mental model is:

  • the GameObject is the thing in the scene
  • native components give it engine capabilities
  • your Behaviour coordinates those components into gameplay

For example, a player ship might have a PlayerController Behaviour. That Behaviour can read input, update the ship's Transform or Rigidbody, tell the animation component which state to play, and ask a weapon component to fire.

Lifecycle Methods

Behaviours use lifecycle methods so your code runs at the right time.

The most common ones are:

  • awake() when the Behaviour instance is loaded
  • start() before the first frame update
  • update() once per frame
  • lateUpdate() once per frame after all update() methods have run
  • fixedUpdate() on the fixed timestep used for physics-style work
  • onEnable() and onDisable() when the Behaviour becomes active or inactive
  • onDestroy() when the Behaviour is removed or destroyed

You do not need all of them in every Behaviour. Start with the one that matches the job.

Use lateUpdate() for work that should happen after regular per-frame gameplay has had a chance to move objects, such as follow cameras, cleanup passes, or presentation code that depends on final frame positions.

Inspector Fields

Behaviours can expose fields to the Inspector.

That lets you tune gameplay values without editing code every time.

For example, movement speed, jump force, fire rate, patrol points, audio clips, and references to other scene objects are all good candidates for Inspector fields.

This is one of the main reasons to choose a Behaviour instead of a plain PHP helper: it can be authored and tuned as part of the scene.

What to Read Next