From UE4: Community Wiki
Jump to: navigation, search

This article is a preliminary version, it is subject to change.


Actor is one of the most important aspects of Unreal Engine, it lays at the core of everything you will do interacting in the Unreal Editor viewport and the Game World. This core Unreal Engine Class AActor forms the basis for any Object you can see in the viewport in the 3d space, this does not include UMG widgets which are overlays.


Actors are made up of various Components.


There are a class of Actors which have very minimal presence in the game world, they are largely managers and extend from the Info Actor. See Game Framework explained for more.


Spawning refers to the process of creating an Actor, similar to New Object though having a physical presence in the game world means Actors are treated differently, because they have components like collision. If an Actors Spawn location is being blocked we call that Encroachment, its when two Actors (or more) share the same physical space.


Since there is a requirement to having a game world we must first GetWorld to call Spawn on, this function is inherited by all Actors. This is the most basic implementation calling the default constructor.

	FActorSpawnParameters SpawnInfo;
	SpawnInfo.Owner = this;
	SpawnInfo.Instigator = GetInstigator();
	SpawnInfo.ObjectFlags |= RF_Transient;
	YourActorReference = GetWorld()->SpawnActor<AYourActor>(SpawnInfo);

Spawning has the associated structure FActorSpawnParameters which is used to pass in a number of parameters to the Spawn function as in this example.

GetWorld()->SpawnActor<AYourActor>(YourActorClass, SpawnInfo);

The above lets you specify a class with YourActorClass you may wish this to be editable on children of this class.

Spawn Actor API

Spawning Actors in C++




If you are finished with an Actor simply call the Destroy method.

can bind delegates to spawn/destroy events


This structure FActorSpawnParameters gives us an opportunity to use another existing Actor as a Template for spawning, as shown below with YourTemplateActor reference being set to use when Spawned.

	FActorSpawnParameters SpawnInfo;
	SpawnInfo.Owner = this;
	SpawnInfo.Template = YourTemplateActor;
	YourActorReference = GetWorld()->SpawnActor<AYourActor>(SpawnInfo);


Attaching Actors typically happens through their Components, the most basic form of attachment would be through two Actors Root Components using AttachToActor.


You can also optionally use the named socket or FAttachmentTransformRules.

AttachToActor(ParentActor, FAttachmentTransformRules, SocketName);
AttachToComponent(USceneComponent * Parent, FAttachmentTransformRules, SocketName);

To check to see if your attachment worked.

USceneComponent* AttachComponent = YourActor->GetDefaultAttachComponent();
TArray <AActor*> YourOutActors,
YourActor->GetAttachedActors(&YourOutActors, false);

YourOutActors array is now filled with a list of all Actors attached to YourActor.

ParentActor = YourActor->GetAttachParentActor();



Detaches the RootComponent of this Actor from any SceneComponent it is currently attached to.

YourActor->DetachAllSceneComponents(ParentComponent, FDetachmentTransformRules);


FName  	GetAttachParentSocketName()


FText* Reason = "";
if(YourActor->EditorCanAttachTo(YourParent, Reason){}


Actor Channels[edit]

Further Reading[edit]

Actors Architecture