MultiWorld 1.9.1
Manage multiple isolated UWorld instances simultaneously in Unreal Engine, transferring player and actors between worlds.
|
Static class with MultiWorld functions that can be called from both Blueprint and C++. More...
#include <MultiWorldStatics.h>
Static Public Member Functions | |
static bool | AreWorldsEquals (const FMultiWorldHandle &InWorldHandleA, const FMultiWorldHandle &InWorldHandleB) |
Return true if the two world handle(s) are equals (they refer to the same world), false otherwise. More... | |
static void | EndWorld (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle) |
Call the EndPlay to the input World and to all its actors; The World and all actors are destroyed. More... | |
static void | ExecuteConsoleCommandInWorld (const FMultiWorldHandle &InWorldHandle, const FString &Command) |
Executes a console command on a specific world. More... | |
static FMultiWorldHandle | GetActiveWorldHandle (const UObject *WorldContextObject) |
Return the world handle of the active World. More... | |
static class AActor * | GetActorOfClass (const FMultiWorldHandle &InWorldHandle, TSubclassOf< AActor > ActorClass) |
Find the first Actor in the world of the specified class. More... | |
static void | GetAllActorsOfClass (const FMultiWorldHandle &InWorldHandle, TSubclassOf< AActor > ActorClass, TArray< AActor * > &OutActors) |
Find all Actors in the world of the specified class. More... | |
static void | GetAllActorsOfClassWithTag (const FMultiWorldHandle &InWorldHandle, TSubclassOf< AActor > ActorClass, FName Tag, TArray< AActor * > &OutActors) |
Find all Actors in the world of the specified class with the specified tag. More... | |
static void | GetAllActorsWithInterface (const FMultiWorldHandle &InWorldHandle, TSubclassOf< UInterface > Interface, TArray< AActor * > &OutActors) |
Find all Actors in the world with the specified interface. More... | |
static void | GetAllActorsWithTag (const FMultiWorldHandle &InWorldHandle, FName Tag, TArray< AActor * > &OutActors) |
Find all Actors in the world with the specified tag. More... | |
static void | GetAllObjectsWithInterface (const FMultiWorldHandle &InWorldHandle, TSubclassOf< UInterface > Interface, TArray< UObject * > &OutObjects) |
Find all UObject(s) in the world with the specified interface. More... | |
static FMultiWorldHandle | GetMainWorldHandle (const UObject *WorldContextObject) |
Return the main world handle. More... | |
static class APlayerController * | GetPlayerController (const UObject *WorldContextObject, int32 PlayerIndex) |
Returns the player controller found while iterating through the local available player controllers. More... | |
static FMultiWorldHandle | GetThisWorldHandle (const UObject *WorldContextObject) |
Return the world handle where the caller lives. More... | |
static FMultiWorldHandle | GetWorldHandleByName (const UObject *WorldContextObject, FName WorldName) |
Return the world handle of the world with the given name if found or an invalid handle otherwise. More... | |
static void | InitializeWorld (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle) |
Setup the input World for playing; Actors are intialized, BeginPlay is called etc... After you call this method, you can switch world calling SwitchWorld. More... | |
static bool | IsValidHandle (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle) |
Return true if the input world handle is valid, false otherwise. More... | |
static void | LoadWorldAsyncWithDelegate (const UObject *WorldContextObject, TSoftObjectPtr< UWorld > InMapAsset, FMultiWorldLoadParameters InParams, FOnLoadWorldCompletedDelegateSimple OnComplete) |
Asynchronously load a World into memory. More... | |
static void | LoadWorldWithDelegate (const UObject *WorldContextObject, TSoftObjectPtr< UWorld > InMapAsset, FMultiWorldLoadParameters InParams, FOnLoadWorldCompletedDelegateSimple OnComplete) |
Synchronously load a World into memory. More... | |
static void | RequestSwitchWorld (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle) |
Like SwitchWorld() but the switch will take place in the next frame and outside the worlds ticking. More... | |
static bool | ReturnToMainWorld (const UObject *WorldContextObject) |
Travel the local players to the main world. More... | |
static void | SetAutoHandleWidgetsForMainWorld (const UObject *WorldContextObject, bool bAutoHandleWidgets) |
Sets whenever the UMG main world widgets must be handled automatically or not (shown when the world is active, hidden when the world is not). More... | |
static void | SetPhysicsActorTransform (AActor *Actor, const FTransform &NewTransform, ETeleportType Teleport=ETeleportType::ResetPhysics) |
Set the Actor transform, moving also all attached physics bodies as a single entity. More... | |
static void | SetShouldTickWhenInBackground (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle, bool bShouldTick) |
Sets whether or not the input world is ticked by the engine when it is in background (when not in play). More... | |
static AActor * | SpawnActorInWorld (const UObject *WorldContextObject, TSubclassOf< class AActor > ActorClass, const FMultiWorldHandle &InWorldHandle, const FTransform &SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingOverride, AActor *Owner) |
Create an actor and place it in the input world. More... | |
static bool | SwitchWorld (const UObject *WorldContextObject, const FMultiWorldHandle &InWorldHandle) |
Change the Active World, travelling the local players to the input world. More... | |
static void | TransferActorToWorld (const UObject *WorldContextObject, AActor *InActor, const FMultiWorldHandle &InWorldHandle, const FMultiWorldTransferActorParameters &Options) |
Transfer the input actor from its actual world to the input one. More... | |
Static class with MultiWorld functions that can be called from both Blueprint and C++.
Few extra features (mainly Delegates) are available using the UMultiWorldManager subsystem.
|
static |
Return true if the two world handle(s) are equals (they refer to the same world), false otherwise.
[in] | InWorldHandleA | first world handle to compare |
[in] | InWorldHandleB | second world handle to compare |
|
static |
Call the EndPlay to the input World and to all its actors; The World and all actors are destroyed.
The input world handle is not more valid after. If InWorldHandle is the active world (equals to GetActiveWorldHandle()), ReturnToMainWorld is called automatically. Can NOT be called with the main world handle (GetMainWorldHandle() is not a valid param). In this case the call doesn't have any effect.
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle |
|
static |
Executes a console command on a specific world.
InWorldHandle | The handle of the world where to exec the command |
Command | Command to send to the console |
|
static |
Return the world handle of the active World.
[in] | WorldContextObject | the world context object |
|
static |
Find the first Actor in the world of the specified class.
This is a slow operation, use with caution e.g. do not use every frame.
InWorldHandle | The handle of the world where find the actor. |
ActorClass | Class of Actor to find. Must be specified or result will be empty. |
|
static |
Find all Actors in the world of the specified class.
This is a slow operation, use with caution e.g. do not use every frame.
InWorldHandle | The handle of the world where find the actors. |
ActorClass | Class of Actor to find. Must be specified or result array will be empty. |
OutActors | Output array of Actors of the specified class. |
|
static |
Find all Actors in the world of the specified class with the specified tag.
This is a slow operation, use with caution e.g. do not use every frame.
InWorldHandle | The handle of the world where find the actors. |
Tag | Tag to find. Must be specified or result array will be empty. |
ActorClass | Class of Actor to find. Must be specified or result array will be empty. |
OutActors | Output array of Actors of the specified tag. |
|
static |
Find all Actors in the world with the specified interface.
This is a slow operation, use with caution e.g. do not use every frame.
InWorldHandle | The handle of the world where find the actors. |
Interface | Interface to find. Must be specified or result array will be empty. |
OutActors | Output array of Actors of the specified interface. |
|
static |
Find all Actors in the world with the specified tag.
This is a slow operation, use with caution e.g. do not use every frame.
InWorldHandle | The handle of the world where find the actors. |
Tag | Tag to find. Must be specified or result array will be empty. |
OutActors | Output array of Actors of the specified tag. |
|
static |
Find all UObject(s) in the world with the specified interface.
This is a slow operation, use with caution e.g. do not use every frame.
InWorldHandle | The handle of the world where find the actors. |
Interface | Interface to find. Must be specified or result array will be empty. |
OutObjects | Output array of UObject(s) of the specified interface. |
|
static |
Return the main world handle.
The main world is the world loaded by the Unreal Engine itself.
[in] | WorldContextObject | the world context object |
|
static |
Returns the player controller found while iterating through the local available player controllers.
The implementation is equal to UGameplayStatics::GetPlayerController (UE 4.26)
WARNING: the new implementation of UGameplayStatics::GetPlayerController (UE 5.03) get the player controller from the localplayer and this is wrong when it's called outside the world tick (e.g delegates). So in UE5 this function must be used instead of UGameplayStatics::GetPlayerController whenever you need to get the player controller in a world but the caller comes from a different world.
[in] | WorldContextObject | the world context object |
[in] | PlayerIndex | the local player index for which to return the player controller |
|
static |
Return the world handle where the caller lives.
Technically it's the UWorld of the World Context Object implicitly passed by UE5 to the function.
[in] | WorldContextObject | the world context object |
|
static |
Return the world handle of the world with the given name if found or an invalid handle otherwise.
If two or more worlds have the same name, the first found is returned.
[in] | WorldContextObject | the world context object |
[in] | WorldName | the name of the world to looking for |
|
static |
Setup the input World for playing; Actors are intialized, BeginPlay is called etc... After you call this method, you can switch world calling SwitchWorld.
[in] | WorldContextObject | the world context object |
InWorldHandle | the world to setup; it should came from the function LoadWorld. |
|
static |
Return true if the input world handle is valid, false otherwise.
[in] | WorldContextObject | the world context object |
[in] | InWorldHandle | the world handle to check |
|
static |
Asynchronously load a World into memory.
The map and related assets are loaded asynchronously, using LoadPackageAsync().
In addition to the OnComplete delegate, you can also use the delegate UMultiWorldManager::OnLoadWorldCompleted to be notified when the load is completed.
To load data asynchronously, the project setting "Async Loading Thread Enabled" MUST be enabled (under section "Engine - Streaming") and project data MUST be cooked.
You can also enable the flag adding in DefaultEngine.ini
:
[in] | WorldContextObject | the world context object |
InMapAsset | the map asset where the World is located. | |
InParams | optional params to customize the loading. | |
OnComplete | delegate called on loading complete. |
|
static |
Synchronously load a World into memory.
This is a blocking call, that do most of its job in the game thread and completes its activity before the end of the current engine frame. To guarantee a proper initialization of the loaded UWorld, some initializations could have to be deferred later in the current engine frame. The OnComplete callback will be called as soon as the initialization is done.
In particular, if this method is called during the BeginPlay of the current world (aka the Active World), the OnComplete callback will be activated soon after the BeginPlay ends.
[in] | WorldContextObject | the world context object |
InMapAsset | the map asset where the World is located. | |
InParams | optional params to customize the loading. | |
OnComplete | delegate called on loading complete. |
|
static |
Like SwitchWorld() but the switch will take place in the next frame and outside the worlds ticking.
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle where to go |
|
static |
Travel the local players to the main world.
The main world is the world loaded by the Unreal Engine itself. If you call from the main world, the call doesn't have any effect.
[in] | WorldContextObject | the world context object |
|
static |
Sets whenever the UMG main world widgets must be handled automatically or not (shown when the world is active, hidden when the world is not).
True by default.
[in] | WorldContextObject | the world context object |
[in] | bAutoHandleWidgets | true if widgets are handled automatically for the main world, false otherwise. |
|
static |
Set the Actor transform, moving also all attached physics bodies as a single entity.
Actor | The Actor to move. |
NewTransform | The new transform. |
Teleport | How we teleport the physics state (see AActor::SetActorTransform()). |
|
static |
Sets whether or not the input world is ticked by the engine when it is in background (when not in play).
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle for which to apply the setting | |
bShouldTick | the "tick-when-in-background" flag |
|
static |
Create an actor and place it in the input world.
[in] | WorldContextObject | the world context object |
[in] | ActorClass | the class to use to create the actor |
[in] | InWorldHandle | the world where to place the actor |
[in] | SpawnTransform | the absolute world transform of the new actor |
[in] | CollisionHandlingOverride | the strategy for handling the case of collision when the actor is spawned |
[in] | Owner | the owner of the new actor |
|
static |
Change the Active World, travelling the local players to the input world.
Secondary Worlds are not replicated.
All actors implementing the interface IMultiWorldActorInterface are notified accordingly to the interface.
The delegate UMultiWorldManager::OnWorldSwitched is notified.
UMG widgets are managed accordingly to the configuration (see FMultiWorldLoadParameters::bAutoHandleWidgets and SetAutoHandleWidgetsForMainWorld()).
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle where to go |
|
static |
Transfer the input actor from its actual world to the input one.
It's not network-replicated.
[in] | WorldContextObject | the world context object |
InActor | the actor to transfer | |
InWorldHandle | the new world of the input actor | |
Options | Options to customize the transfer (including setting a final transform for the actor). |