UDN
Search public documentation:

ArchetypesTechnicalGuide
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > UnrealScript > Archetypes Technical Guide
UE3 Home > Gameplay Programming > Archetypes Technical Guide

Archetypes Technical Guide

Overview


Archetypes allow designers to take a snapshot of an existing Actor (including property values, components, object references), and save that snapshot as a placeable content resource, or template. Archetypes are stored in normal Unreal package files which are managed by designers, and allow the designer to place instances of the Archetype in maps, sequences, and UI scenes without requiring any programmer involvement. If a designer changes the default value of a property in an Archetype, that value is automatically propagated to all instances of that Archetype in existing levels and content except those instances which have had that property value customized. Changes to Archetype properties are propagated immediately to instances in the currently open level, and propagated to instances in other packages the next time those packages are loaded.

Archetypes in Unreal Editor

Archetypes are represented in the editor as placeable resources, in the same way that Classes are placeable resources. In fact, it helps to think of Archetypes as "script-less classes", where the purpose of the Archetype is to provide a way for designers to place an Actor that using a set of default property values which are different from the Actor's class defaults. Archetypes appear in the Content Browser, and provide the same behaviors and functionality as any other resource type, in they can be filtered so that only packages which contain Archetypes appear in the Content Browsers list of packages, etc.

Even though Archetypes can be considered to be "script-less classes," they are not located in the Actor Class Browser at this time.

Instancing Archetypes


In Unreal Editor

Once you've created an Archetype, it's time to start using them in your levels. The procedure for placing instances of Archetypes is very similar to the procedure for placing normal Actors. See the Using Archetypes page for more details on how to do this.

In Unrealscript

There are two ways to create an instance of an Archetype from code.

In UnrealScript, objects are created using the new operator. The UnrealScript new operator takes five parameters; the last parameter is the template to use for the new object. To instance an Archetype in Unrealscript, pass a reference to an existing Archetype as the value for the template parameter.

var StaticMesh MeshArchetype;
var StaticMeshActor MeshActorTemplate;

// Object archetype instancing example
function CreateObjectArchetype()
{
  local StaticMesh MeshInstance;

  // create a new StaticMesh object in the transient package using the value of MeshArchetype as the template
  MeshInstance = new Class'Object'(MeshArchetype);
}

// Actor archetype instancing example
function CreateActorArchetype()
{
  local StaticMeshActor MeshActorInstance;

  // now spawn the Actor, passing in the Archetype reference as the template
  MeshActorInstance = Spawn(class'StaticMeshActor', None, 'None', Location, Rotation, MeshActorTemplate);
}

defaultproperties
{
  MeshArchetype=Object'SomeArchetypePackge.MyArchetype'
  MeshActorTemplate=StaticMeshActor'SomeArchetypePackage.SMArchetype'
}

How Archetypes differ from prefabs


Archetypes differ from prefabs in the following manner:
  1. Prefabs are composed of archetypes
  2. Prefabs can contain sequences (Kismet)
  3. Prefabs preserve and translate object references within the prefab

For more information on Prefabs, see the Using Prefabs page.