TeleportService

Provides the function to move an entity to a specific location and warp users to another World instance.

# Methods

[{"index":"void ClearReservation() (Server)","0":"Cancels scheduled teleports."}]

[{"index":"void ClearReservation(Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other ClearReservation() function."}]

[{"index":"WarpRecord GetWarpRecord(string userId) (ServerOnly)","0":"Acquires the warp records of the user corresponding to userId."}]

[{"index":"boolean ReserveTeleportToEntity(Entity targetEntity, Entity destinationEntity, boolean overridePrevious = true) (Server)","0":"Schedules a teleport to the same location as the Entity set as the destination."}]

[{"index":"boolean ReserveTeleportToEntity(Entity targetEntity, Entity destinationEntity, boolean overridePrevious = true, Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other ReserveTeleportToEntity(Entity, Entity, boolean) function."}]

[{"index":"boolean ReserveTeleportToMapPosition(Entity targetEntity, Vector3 destinationPosition, string destinationMapName = \"\", boolean overridePrevious = true) (Server)","0":"Schedules a teleport to your destination location."}]

[{"index":"boolean ReserveTeleportToMapPosition(Entity targetEntity, Vector3 destinationPosition, string destinationMapName = \"\", boolean overridePrevious = true, Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other ReserveTeleportToMapPosition (Entity, Vector3, string, boolean) function."}]

[{"index":"void TeleportReservedEntities() (Server)","0":"Executes scheduled teleports."}]

[{"index":"void TeleportReservedEntities(Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other TeleportReservedEntities() function."}]

[{"index":"void TeleportToEntity(Entity targetEntity, Entity destinationEntity) (Server)","0":"Teleports the Entity to the location of the destination Entity."}]

[{"index":"void TeleportToEntity(Entity targetEntity, Entity destinationEntity, Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other TeleportToEntity(Entity, Entity) function."}]

[{"index":"void TeleportToEntityPath(Entity targetEntity, string destinationEntityPath) (Server)","0":"Teleports the Entity to the location of the destination Path."}]

[{"index":"void TeleportToEntityPath(Entity targetEntity, string destinationEntityPath, Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other TeleportToEntityPath(Entity, string)."}]

[{"index":"void TeleportToMapPosition(Entity targetEntity, Vector3 destinationPosition, string destinationMapName = \"\") (Server)","0":"Teleports an Entity to the destination location."}]

[{"index":"void TeleportToMapPosition(Entity targetEntity, Vector3 destinationPosition, string destinationMapName = \"\", Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other TeleportToMapPosition (Entity, Vector3, string) function."}]

[{"index":"void UnReserveTeleport(Entity targetEntity) (Server)","0":"Cancels scheduled teleports."}]

[{"index":"void UnReserveTeleport(Entity targetEntity, Entity messageOwnerEntity = nil) (Deprecated) (Server)","0":"This function is now deprecated. Use the other UnReserveTeleport(Entity) function."}]

[{"index":"boolean WarpAdminToWorldInstanceAndWait(string userId, string destinationWorldInstanceId, string warpData) (ServerOnly) (ReleaseOnly) (Yield)","0":"Warps a creator with world creation permissions or a cooperation group member to a world instance and returns the success status.Warp is only available to released worlds that are public. Script executions are suspended during the performance. This function only acts in release environments. Returns false when executed from Maker.Entry is possible even if there is no room in a world instance and an entry will not be reflected on the player list.The userId is the Id of the user that will be warped, and the destinationWorldInstanceId is the destination world's instance Id. Data delivered with warpData can be viewed from the GetWarpRecord function."}]

[{"index":"void WarpAdminToWorldInstanceAsync(string userId, string destinationWorldInstanceId, string warpData, func callbackFunction) (ServerOnly) (ReleaseOnly)","0":"Warps a creator with world creation permissions or a cooperation group member to a world instance. Warp is only available to released worlds that are public. This function only acts in release environments. Returns false when executed from Maker. This work is executed asynchronously, and when the work is complete, it calls the function that was delivered to callbackFunction as well as the success status. Entry is possible even if there is no room in a world instance and an entry will not be reflected on the player list. The userId is the Id of the user that will be warped, and the destinationWorldInstanceId is the destination world's instance Id. Data delivered with warpData can be viewed from the GetWarpRecord function."}]

[{"index":"boolean WarpUsersToWorldAndWait(table userIds, string destinationWorldId, string warpData) (ServerOnly) (Yield)","0":"Warps users to another world and returns whether the operation was successful or not. Only the open worlds among the released games can be set as a target world. Script executions are suspended during operation.userIds are the Ids of the users who will be warped, and destinationWorldInstanceId is the Id of the target world instance. Data passed to warpData can be checked using the GetWarpRecord function."}]

[{"index":"void WarpUsersToWorldAsync(table userIds, string destinationWorldId, string warpData, func callbackFunction) (ServerOnly)","0":"Warps users to another World. Only the open Worlds among the released games can be set as a target World. This operation is performed asynchronously, and the function passed to the callbackFunction is called whether successful or not upon the operation's completion.The userId is the Id of the user who will be warped, and destinationWorldId is the Id of the target World. Data passed to warpData can be checked using the GetWarpRecord function."}]

[{"index":"boolean WarpUserToWorldAndWait(string userId, string destinationWorldId, string warpData) (ServerOnly) (Yield)","0":"Warps a user to another world and returns whether the operation was successful or not. Only the open worlds among the released worlds can be set as a target world. Script executions are suspended during operation.userId is the Id of the user who will be warped, and destinationWorldId is the Id of the target world. Data passed to warpData can be checked using the GetWarpRecord function."}]

[{"index":"void WarpUserToWorldAsync(string userId, string destinationWorldId, string warpData, func callbackFunction) (ServerOnly)","0":"Warps a user to another World. Only the open Worlds among the released games can be set as a target World. This operation is performed asynchronously, and the function passed to the callbackFunction is called whether successful or not upon the operation's completion.The userId is the Id of the user who will be warped, and destinationWorldId is the Id of the target World. Data passed to warpData can be checked using the GetWarpRecord function."}]

[{"index":"boolean WarpUserToWorldInstanceAndWait(string userId, string destinationWorldInstanceId, string warpData) (ServerOnly) (ReleaseOnly) (Yield)","0":"Warps a user to another World instance and returns whether the operation was successful or not. Only the open Worlds among the released games can be set as a target World. Script executions are suspended during operation.The userId is the Id of the user who will be warped, and destinationWorldInstanceId is the Id of the target World instance. Data passed to warpData can be checked using the GetWarpRecord function. This function only works in the release environment. If executed in the Maker, false will be returned."}]

[{"index":"void WarpUserToWorldInstanceAsync(string userId, string destinationWorldInstanceId, string warpData, func callbackFunction) (ServerOnly) (ReleaseOnly)","0":"Warps a user to another World instance. Only the open Worlds among the released games can be set as a target World. This operation is performed asynchronously, and the function passed to the callbackFunction is called whether successful or not upon the operation's completion.The userId is the Id of the user who will be warped, and destinationWorldInstanceId is the Id of the target World instance. Data passed to warpData can be checked using the GetWarpRecord function.This function only works in the release environment. If executed in the Maker, false will be returned."}]

##### inherited from Service:

[{"index":"EventHandlerBase ConnectEvent(string key, IScriptFunction eventHandler)","0":"Links events. When a key-type event occurs in this service, a handler is notified. The handler receives event parameters."}]

[{"index":"EventHandlerBase ConnectEvent(Type eventType, IScriptFunction eventHandler)","0":"Links events. This service notifies a handler when an eventType event occurs. The handler receives event parameters."}]

[{"index":"boolean DisconnectEvent(string key, EventHandlerBase eventHandler)","0":"Disconnects the event with the key-type event and the handler."}]

[{"index":"boolean DisconnectEvent(Type eventType, EventHandlerBase eventHandler)","0":"Disconnects the eventType event from its handler."}]

[{"index":"void SendEvent(EventType sendEvent)","0":"Generates an event."}]

# Examples

This example creates a skill that drives surrounding monsters together to attack them.

If you press the LeftShift key, you will find monsters using the preset tag and collect the found monsters at your character’s location.  
Then the character climbs higher than that location and attacks the monsters.
    
    
    @Component
    script MonsterGatherer extends Component
        @EventSender("Service", "InputService")
        handler HandleKeyDownEvent(KeyDownEvent event)
        -- Parameters
        local key = event.key
        --------------------------------------------------------
    
        if key == KeyboardKey.LeftShift then
        	local me = _UserService.LocalPlayer
        	local currentMapName = me.CurrentMapName
        	local currentPosition = me.TransformComponent.Position
        	local allMonsters = _EntityService:GetEntitiesByTag("Monster")
    
        	for i = 1, #allMonsters do
        		_TeleportService:TeleportToEntity(allMonsters[i], me)
        	end
    
        	_TeleportService:TeleportToMapPosition(me, currentPosition + Vector3(0, 2, 0), currentMapName)
        end
        end
    end
    

# SeeAlso

  * TransformComponent
  * KeyDownEvent
  * EntityService
  * UserService
  * [Teleportation](/docs?postId=59)
  * [Warp World](/docs?postId=743)
  * [Warping to a Specific World Instance](/docs?postId=1122)