UGameplayTask_SpawnActor

Convenience task for spawning actors (optionally limiting the spawning to the network authority).

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

GameplayTasks

Header

/Engine/Source/Runtime/GameplayTasks/Classes/Tasks/GameplayTask_SpawnActor.h

Include

#include "Tasks/GameplayTask_SpawnActor.h"

Syntax

class UGameplayTask_SpawnActor : public UGameplayTask

Remarks

Convenience task for spawning actors (optionally limiting the spawning to the network authority). If not the net authority, we will not spawn and Success will not be called. The nice thing this adds is the ability to modify expose on spawn properties while also implicitly checking network role before spawning.

Though this task doesn't do much - games can implement similar tasks that carry out game specific rules. For example a 'SpawnProjectile' task that limits the available classes to the games projectile class, and that does game specific stuff on spawn (for example, determining firing position from a weapon attachment).

Long term we can also use this task as a sync point. If the executing client could wait execution until the server creates and replicates the actor down to him. We could potentially also use this to do predictive actor spawning / reconciliation.

Variables

Name Description

Protected variable

FVector

 

CachedSpawnLocation

Protected variable

FRotator

 

CachedSpawnRotation

Protected variable

TSubclassOf < AA ...

 

ClassToSpawn

Public variable

FGameplayTaskSp ...

 

DidNotSpawn

Called when we can't spawn: on clients or potentially on server if they fail to spawn (rare)

Public variable

FGameplayTaskSp ...

 

Success

Functions

Name Description

Public function Virtual

bool

 

BeginSpawningActor

(
    UObject * WorldContextObject,
    AActor *& SpawnedActor
)

Public function Virtual

void

 

FinishSpawningActor

(
    UObject * WorldContextObject,
    AActor * SpawnedActor
)

Public function Static

UGameplayTas ...

 

SpawnActor

(
    TScriptInterface < IGameplayTaskOwne ...,
    FVector SpawnLocation,
    FRotator SpawnRotation,
    TSubclassOf < AActor > Class,
    bool bSpawnOnlyOnAuthority
)

Spawn new Actor on the network authority (server)

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback