跳至正文
版本:bleeding-edge 🩸

维度

关于维度你需要了解的一切

维度是什么​

维度是客户端中分开的世界,玩家和 Actor 在其中是分开的。在 nanos world 中,它们用数字表示。最多可以有 65,535 个不同的维度。

默认情况下,所有玩家和实体都在维度 1 中。将玩家移到另一个维度后,所有不属于该维度的实体对该玩家来说都会被销毁,而新维度中的所有实体都会为他生成。

如何使用​

To send an actor or a player to another dimension, the API is very simple (only on the server side):

Server/Index.lua
my_actor:SetDimension(2)
my_player:SetDimension(2)

To send a remote event to all players in a dimension, use:

Server/Index.lua
-- Sends "MatchStarted" to all players in the dimension 2
Events.BroadcastRemoteDimension("MatchStarted", 2, Reliability.Reliable, "some data")

And to send a remote event to players in a dimension near a location, use Events.BroadcastRemoteInRadiusDimension().

You can also change in which dimension new Players and new Entities start with Server.SetDefaultPlayerDimension() and Server.SetDefaultEntityDimension().

Whenever an Actor or a Player changes its dimension, the DimensionChange event is triggered on it.

备注

如果通过远程事件发送与玩家不在同一维度的实体,则参数将被替换为 nil,并显示警告。

Actor 层级​

通过发送一个实体,它的“子实体”也会被移动到那个维度,例如:

  • 发送一个 Actor 时,所有其他附加的 Actor 也会随之移动。
  • 发送玩家时,角色也会移动。
  • 发送角色时,玩家不会一起移动,但拾取的武器或道具(以及附加的 Actor)会一起移动。
  • 发送载具时,所有角色都会离开载具(此功能很快™会得到改进)。