Guides Components What Is a Component?

Components 2 min read Updated Apr 2026

What Is a Component?

A component is one capability attached to a GameObject.

The GameObject is the container. Components are the parts that make the object render, collide, play audio, run code, or participate in other engine systems.

Why Components Exist

Components let one GameObject be built from small focused pieces.

Instead of making a special object type for every possible combination, you attach the capabilities you need.

For example:

  • a Sprite Renderer draws a 2D sprite
  • a Rigidbody2D lets physics move an object
  • a BoxCollider2D gives an object a collision shape
  • an AudioSource plays sounds
  • a Behaviour runs scene-attached PHP gameplay code

Each component has a narrow job.

Components in the Inspector

When you select a GameObject, the Inspector shows its components as stacked sections.

Each section belongs to one component.

The Inspector showing a P1 Paddle GameObject with Transform, Rectangle Renderer, and Paddle Behaviour components stacked underneath the GameObject header.

In this example:

  • Transform gives the paddle position, rotation, and scale
  • Rectangle Renderer draws the paddle as a visible rectangle
  • Paddle is a Behaviour component with game-specific input and movement settings

That is where you edit component fields such as:

  • sprite or texture references
  • physics settings
  • Behaviour-exposed values
  • enabled or disabled state
  • object references

This is one of the main reasons the editor exists: it lets designers and developers tune component data without editing scene files by hand.

Components and Behaviours

A Behaviour is a component too.

Native components are built into the engine. A Behaviour is a PHP class you attach to a GameObject when that object needs project-specific gameplay logic.

That means a Behaviour can live beside native components and coordinate them.

For example, a PlayerController Behaviour might read input, then update a Rigidbody2D, a SpriteAnimation, and a weapon component attached to the same GameObject.

Not every PHP class in a project needs to be a Behaviour. Use plain PHP classes for helpers, calculations, data structures, and services that do not need GameObject ownership or Inspector fields. Use enums when a value has a clear set of named choices.

Good Component Thinking

A useful rule is: give each component one clear responsibility.

For example:

  • movement logic belongs in a movement Behaviour
  • weapon firing belongs in a weapon Behaviour
  • collision shape belongs in a collider component
  • rendering belongs in a renderer component
  • damage formulas can live in a plain PHP class

That keeps GameObjects understandable when you return to them later.

What to Read Next