Learn

Chapter 06 Actors & Components

#060 Child Actor Components

A turret that's its own actor, mounted on a tank, and spawned with it automatically? Use a Child Actor Component.

  • 1:52 video
  • Written lesson
  • Beginner
Video lesson: Child Actor Components, 1:52

An actor inside another actor

A Child Actor Component spawns a whole actor, using whatever class you pick in Child Actor Class.

  • The child spawns together with its parent, and it’s destroyed along with that parent.
  • It’s attached to that component, so it follows the component’s transform.
  • But the child is still a separate actor, with its own Begin Play, its own Tick, and its own variables.

To talk to it, call Get Child Actor. It returns a plain Actor reference, so cast it to your class first.

Set Child Actor Class swaps it during play: the old child is destroyed, and a new one spawns.

Example: a tank turret

A tank has a Child Actor Component set to BP Turret.

  • Spawn the tank, and its turret spawns with it, already in place.
  • Drive the tank, and the turret rides along.
  • On Begin Play, Get Child Actor, Cast To BP Turret, and call its Fire event.
  • Destroy the tank, and the turret is destroyed too.

Chapter six recap: actors and components

  • Actors are things in your level, components are their parts, and the root sets the transform.
  • Construction Script, Begin Play, Tick and End Play run in a fixed order.
  • Spawn Actor from Class creates actors during play, placed by a Spawn Transform, and Destroy Actor removes them.
  • Scene Components are pivots, Static Mesh Components draw your models, and tags mark roles across classes.
  • Attaching makes one actor follow another.

Three final tips

  • Check spawned and cast references with Is Valid before you use them.
  • Set Mobility to Movable on anything that moves or changes during play.
  • Never search for tagged actors every frame. Search once, and store the result.

Next, chapter seven: collision and world queries, starting with Collision Presets.

In short

An actor that lives inside another actor.

Covered in this lesson

  • Child Actor Component
  • Child Actor Class
  • Get Child Actor
  • Cast To
  • Set Child Actor Class
  • Is Valid
  • Set Mobility

Newsletter

Development updates are coming to your inbox.

The newsletter opens soon. Until then, new lessons, tools and Beach Hunters progress appear first on our channels, linked below.