AActor
- Module
- Game
- Header
#include "Game/AActor.h"- Namespace
Mowo- Reflection
- Reflected by MowoHeaderTool
Properties
| Type | Name | Description |
|---|---|---|
ETickGroup | primaryTickGroup | Default is PrePhysics — flip in subclass ctor when ordering matters. Default ETickGroup::PrePhysics. |
bool | canEverTick | UE's bCanEverTick: actors that opt out never enter the tick schedule at all — the dominant case for placed scenery. Defaults ON for compatibility; subclasses (and the Visual Script bind, which knows whether any Tick graph or latent node exists in the chain) flip it off. Default true. |
bool | tickOnAnyThread | UE's bRunOnAnyThread: the world may run this actor's tick (its tickInterval pacing, the virtual Tick and the components it ticks) on a task-graph worker, in parallel with the group's other such actors once their prerequisites have ticked. Off by default, and only for an actor whose tick touches nothing but its own state — no spawning or destroying, no structural ECS work, no Visual Scripting, no other actor's fields. Components with a tickGroupOverride still tick on the game thread. Default false. |
float | CustomTimeDilation | Per-actor multiplier on top of the world's time dilation, so a single actor can run in slow motion (or keep full speed while the rest of the world is slowed) without a second clock. The world reads it when it computes this actor's tick delta; 1 = follow the world exactly, 0 = frozen. Default 1.0f. |
float | tickInterval | Tick pacing (UE TickInterval): 0 = every frame. When set, the world accumulates this actor's dilated time and Tick fires once the interval elapses, receiving the ACCUMULATED delta — dt-integrating gameplay stays exact, it just steps coarser. The cost lever for things that don't need per-frame updates (distant AI, ambience). Default 0.0f. |
Constructors
Public functions
| Returns | Name | Description |
|---|---|---|
void | OnConstruct | Construction event (UE Construction Script analog). |
MClass* | GetClass | |
void | SetClassOverride | |
void | RegisterComponents | Publish this actor onto its backing ECS entity. |
void | BeginPlay | Called once when the world begins play, or at registration for an actor spawned into a world that already has. |
bool | HasActorBegunPlay | True between the world's BeginPlay and EndPlay. |
void | DispatchTick | Non-virtual dispatch the world calls: applies tickInterval pacing BEFORE the virtual Tick, so subclass overrides pace with it. |
void | TickOverrideComponents | World-driven pass for components whose tickGroupOverride names this group: they tick AFTER every actor of the group, regardless of the owner's own group. |
void | Tick | Per-frame tick. |
bool | ShouldTickInEditor | Editor-time actors (UE's ShouldTickIfViewportsOnly). |
void | TickInEditor | |
bool | IsEditorWorld | True while this actor's world is the level being authored. |
bool | IsTransient | Generated content: an actor (or component) an editor-time actor created for preview is transient. |
void | SetTransient | |
AActor* | GetGeneratedOwner | |
void | SetGeneratedOwner | |
void | MarkGenerated | Makes generated this actor's transient output: transient, owned by this actor, so it is cleaned up with it. |
void | ClearGeneratedContent | Destroys every actor this one generated and drops its transient components; call it before regenerating and from EndPlay. |
EEndPlayReason | GetEndPlayReason | |
void | Destroyed | Fired by MWorld::Destroy right before EndPlay — the explicit- destruction hook (UE Destroyed()). |
void | EndPlay | Called when the actor is removed from the world. |
Vec3 | GetLocation | Transform Root transform — typically the root MSceneComponent's transform. |
Quat | GetRotation | |
Vec3 | GetScale | |
void | SetLocation | |
void | SetRotation | |
void | SetScale | |
bool | GetSocketTransform | Sockets — the named attachment points a mesh carries (a muzzle, a hand bone, a roof mount). |
bool | HasSocket | |
Vec3 | GetSocketLocation | |
Vec3 | GetActorLocation | |
void | SetActorLocation | |
bool | CanMoveAtRuntime | False for a Static or Stationary actor once its world has begun play (UE's mobility rule); the refused move logs a warning naming the actor. |
std::string | GetActorName | |
void | SetActorHiddenInGame | |
void | AddComponent | Component management Attach a component. |
bool | RemoveComponent | Detach a component added at run time (a script component a designer removed): it leaves the list and loses its owner; the caller ends its play and lets it be collected. |
T* | CreateDefaultSubobject | Convenience for subclass constructors. |
void | InitDefaultSubobjectConfig | The INI's MPROPERTY(Config) values from the component class's default object: a constructor-made component is never cloned from a default, so this is the only way a project's Game.ini reaches it. |
T* | FindComponent | Find first component of the given type. |
const std::vector<MActorComponent*>& | GetComponents | Read-only access to the full component list (for iteration). |
MActorComponent* | GetComponentByClass | The reflected component lookups: by class name (the component's own class or any ancestor, so "MSceneComponent" finds a mesh component) and by the name it was created under. |
MActorComponent* | GetComponentByName | |
int32_t | GetComponentCount | |
MSceneComponent* | GetRootComponent | The scene root — the component whose transform is the actor's transform. |
void | SetRootComponent | |
MWorld* | GetWorld | World |
void | SetWorld | Out-of-line: the TObjectPtr store barrier needs the complete type, and MWorld is only forward-declared here. |
EntityID | GetBackingEntity | ECS bridge Backing entity in the scene's ECS World. |
void | SetBackingEntity | |
void | PullFromBackingEntity | Adoption counterpart to the OnRegister push: seed the root transform from the entity's TransformComponent and fan PullFromMirror out to every component, so re-publishing the mirror reproduces the scene's authored values instead of class defaults. |
void | AddTag | Gameplay tags Hierarchical identifiers (Damage.Physical, Faction.Enemy.Goblin) used for AI behaviour predicates, ability requirements, gameplay filters. |
void | RemoveTag | |
bool | HasTag | |
bool | HasTagExact | |
bool | HasAnyTag | |
const std::vector<std::string>& | GetTags | |
const std::string& | GetArchetypeName | The template (archetype) this instance derives its defaults from, or empty when it derives straight from the class CDO. |
void | SetArchetypeName | |
void | AddTickPrerequisite | Tick prerequisites This actor's Tick runs only after every prerequisite in the SAME tick group has ticked this frame; prerequisites in other groups are already ordered by the group sequence. |
void | RemoveTickPrerequisite | |
const std::vector<TWeakObjectPtr<AActor>>& | GetTickPrerequisites |
Function details
AActor
AActor() = default~AActor
~AActor() override = defaultOnConstruct
virtual void OnConstruct()Construction event (UE Construction Script analog). Runs after the backing entity exists and before BeginPlay; the editor re-runs it when instance properties change, so keep it idempotent — derive state, don't accumulate it. Default: no-op.
GetClass
MClass* GetClass() const overrideSetClassOverride
void SetClassOverride(MClass* cls)RegisterComponents
virtual void RegisterComponents()Publish this actor onto its backing ECS entity. Runs at registration — scene load included — so a placed actor draws and inspects in the editor without beginning play. Default impl dispatches OnRegister to every component; overrides must call Super::RegisterComponents().
BeginPlay
virtual void BeginPlay()Called once when the world begins play, or at registration for an actor spawned into a world that already has. Default impl dispatches BeginPlay to every component — overrides must call Super::BeginPlay(). Gameplay startup only: the ECS mirror is already published by RegisterComponents.
HasActorBegunPlay
bool HasActorBegunPlay() const noexceptTrue between the world's BeginPlay and EndPlay. MWorld owns the flag, which is what makes double-BeginPlay across a PIE Play/Stop/Play cycle impossible.
DispatchTick
void DispatchTick(float deltaSeconds)Non-virtual dispatch the world calls: applies tickInterval pacing BEFORE the virtual Tick, so subclass overrides pace with it.
TickOverrideComponents
void TickOverrideComponents(ETickGroup group, float deltaSeconds)World-driven pass for components whose tickGroupOverride names this group: they tick AFTER every actor of the group, regardless of the owner's own group. Inherit components (-1) tick inside Tick as ever.
Tick
virtual void Tick(float deltaSeconds)Per-frame tick. Default: dispatch to every component's TickComponent. Override on actors that need pre/post-component logic; call Super::Tick(dt) to keep components ticking.
ShouldTickInEditor
virtual bool ShouldTickInEditor() constEditor-time actors (UE's ShouldTickIfViewportsOnly). Off by default: a placed actor is inert in the editor until Play. An actor that previews generated content in edit mode (a procedural world, a spline mesh) returns true and does its work in TickInEditor, which the edit world calls once a frame within the ed.TickBudgetMs budget. Never called in a PIE copy or a game, and not while a Play session replaces the edit world, so the work stops at Play and resumes at Stop. Tick and BeginPlay stay play-only: the default TickInEditor does nothing, it does not forward to Tick.
TickInEditor
virtual void TickInEditor(float deltaSeconds)IsEditorWorld
bool IsEditorWorld() constTrue while this actor's world is the level being authored. Constructors, OnConstruct and RegisterComponents run in the editor as well as in games, so gameplay-only startup asks this.
IsTransient
bool IsTransient() const noexceptGenerated content: an actor (or component) an editor-time actor created for preview is transient. A transient actor is not written to the level, not copied into the Play world (which regenerates its own from BeginPlay), is hidden from the Outliner unless "Show Generated" is on, and selecting it selects its generating owner. Setting transient does not touch the scene's dirty state or the undo stack.
SetTransient
void SetTransient(bool transient) noexceptGetGeneratedOwner
AActor* GetGeneratedOwner() constSetGeneratedOwner
void SetGeneratedOwner(AActor* owner)MarkGenerated
void MarkGenerated(AActor* generated)Makes generated this actor's transient output: transient, owned by this actor, so it is cleaned up with it.
ClearGeneratedContent
void ClearGeneratedContent()Destroys every actor this one generated and drops its transient components; call it before regenerating and from EndPlay. Does nothing for content that is not transient.
GetEndPlayReason
EEndPlayReason GetEndPlayReason() constDestroyed
virtual void Destroyed()Fired by MWorld::Destroy right before EndPlay — the explicit- destruction hook (UE Destroyed()). NOT called on world teardown, play end or ejection; use EndPlay + GetEndPlayReason for those.
EndPlay
virtual void EndPlay()Called when the actor is removed from the world. Counterpart to BeginPlay — default impl dispatches EndPlay to components in reverse order. Overrides must call Super::EndPlay().
GetLocation
Vec3 GetLocation() constTransform Root transform — typically the root MSceneComponent's transform. Convenience accessors mirror to the root component.
GetRotation
Quat GetRotation() constGetScale
Vec3 GetScale() constSetLocation
void SetLocation(const Vec3& v)SetRotation
void SetRotation(const Quat& q)SetScale
void SetScale(const Vec3& v)GetSocketTransform
bool GetSocketTransform(const std::string& socketName, Vec3& outLocation, Quat& outRotation) constSockets — the named attachment points a mesh carries (a muzzle, a hand bone, a roof mount). Asks every scene component on the actor, in attachment order, and returns the first that owns the name; the transform comes back in WORLD space, composed onto the owning component, which is what a caller placing an effect or spawning a projectile actually needs. False leaves the outputs untouched.
HasSocket
bool HasSocket(const std::string& socketName) constGetSocketLocation
Vec3 GetSocketLocation(const std::string& socketName) constGetActorLocation
Vec3 GetActorLocation() constSetActorLocation
void SetActorLocation(const Vec3& location)CanMoveAtRuntime
bool CanMoveAtRuntime() constFalse for a Static or Stationary actor once its world has begun play (UE's mobility rule); the refused move logs a warning naming the actor.
GetActorName
std::string GetActorName() constSetActorHiddenInGame
void SetActorHiddenInGame(bool hidden)AddComponent
void AddComponent(MActorComponent* component)Component management Attach a component. Takes ownership of the raw pointer; the actor will destroy it on EndPlay. Use the templated CreateDefaultSubobject<T>() helper in subclass constructors.
RemoveComponent
bool RemoveComponent(MActorComponent* component)Detach a component added at run time (a script component a designer removed): it leaves the list and loses its owner; the caller ends its play and lets it be collected. False when it was not this actor's.
CreateDefaultSubobject
template<typename T> T* CreateDefaultSubobject(const char* name)Convenience for subclass constructors. Constructs a T, sets its name, attaches to this actor, returns the raw pointer. class APhysicsBox : public AActor { APhysicsBox() { auto* root = CreateDefaultSubobject<MSceneComponent>("Root"); SetRootComponent(root); auto* mesh = CreateDefaultSubobject<MStaticMeshComponent>("Mesh"); mesh->AttachTo(root);
InitDefaultSubobjectConfig
static void InitDefaultSubobjectConfig(MActorComponent* component)The INI's MPROPERTY(Config) values from the component class's default object: a constructor-made component is never cloned from a default, so this is the only way a project's Game.ini reaches it.
FindComponent
template<typename T> T* FindComponent() constFind first component of the given type. Returns nullptr if not attached. O(N) in component count — fine for typical actors with <10 components.
GetComponents
const std::vector<MActorComponent*>& GetComponents() constRead-only access to the full component list (for iteration).
GetComponentByClass
MActorComponent* GetComponentByClass(const std::string& className) constThe reflected component lookups: by class name (the component's own class or any ancestor, so "MSceneComponent" finds a mesh component) and by the name it was created under. Nothing when absent.
GetComponentByName
MActorComponent* GetComponentByName(const std::string& name) constGetComponentCount
int32_t GetComponentCount() constGetRootComponent
MSceneComponent* GetRootComponent() constThe scene root — the component whose transform is the actor's transform. Always an MSceneComponent. nullptr for actors that are pure logic (controllers / managers).
SetRootComponent
void SetRootComponent(MSceneComponent* root)GetWorld
MWorld* GetWorld() constWorld
SetWorld
void SetWorld(MWorld* world)Out-of-line: the TObjectPtr store barrier needs the complete type, and MWorld is only forward-declared here.
GetBackingEntity
EntityID GetBackingEntity() constECS bridge Backing entity in the scene's ECS World. Created by MWorld::RegisterActor when the world has an ECS world attached; INVALID_ENTITY otherwise (pure-logic worlds, tests). Components mirror render/physics state onto it so the flat systems (SceneRenderer's MeshRenderer iteration, TransformSystem) see actors without knowing about the OO layer. MWorld::Tick syncs the root component transform into the entity each frame.
SetBackingEntity
void SetBackingEntity(EntityID id)PullFromBackingEntity
void PullFromBackingEntity(World* ecs)Adoption counterpart to the OnRegister push: seed the root transform from the entity's TransformComponent and fan PullFromMirror out to every component, so re-publishing the mirror reproduces the scene's authored values instead of class defaults.
AddTag
void AddTag(FGameplayTag tag)Gameplay tags Hierarchical identifiers (Damage.Physical, Faction.Enemy.Goblin) used for AI behaviour predicates, ability requirements, gameplay filters. HasTag uses hierarchical matching — a query for "Damage" matches an actor tagged "Damage.Physical.Slash". Storage is a vector of canonical dot-paths rather than a TSet<FGameplayTag>, which is what makes the field reflectable and therefore serialized: MHT maps std::vector<T> to PropertyType::Array and has no set support at all, and FGameplayTag itself is not a reflected struct (its only member is an FName, which is not a PropertyType either). A vector of strings needs nothing new from the header tool, round-trips through the existing scene writer and shows up in the inspector. Uniqueness is enforced in AddTag; actors carry a handful of tags, so the linear scan is not worth a set.
RemoveTag
void RemoveTag(FGameplayTag tag)HasTag
bool HasTag(FGameplayTag tag) constHasTagExact
bool HasTagExact(FGameplayTag tag) constHasAnyTag
bool HasAnyTag(const TSet<FGameplayTag>& s) constGetTags
const std::vector<std::string>& GetTags() const noexceptGetArchetypeName
const std::string& GetArchetypeName() const noexceptThe template (archetype) this instance derives its defaults from, or empty when it derives straight from the class CDO. When set, the scene writer diffs the instance against the named template instead of the CDO (instance -> template -> CDO -> class), so raising a template default reaches every instance of it that never overrode the field.
SetArchetypeName
void SetArchetypeName(const std::string& name)AddTickPrerequisite
void AddTickPrerequisite(AActor* prerequisite)Tick prerequisites This actor's Tick runs only after every prerequisite in the SAME tick group has ticked this frame; prerequisites in other groups are already ordered by the group sequence. Cycles degrade to registration order. Dead prerequisites are ignored and pruned.
RemoveTickPrerequisite
void RemoveTickPrerequisite(AActor* prerequisite)GetTickPrerequisites
const std::vector<TWeakObjectPtr<AActor>>& GetTickPrerequisites() const noexcept