生成地点或“生成”确定在Player重生时在哪里重生点生时。它们可以配置使用Teams。它们还控制如何设置ForceFields对新生成的玩家。
生成地点可以用作检查点,例如在障碍赛中,使用 SpawnLocation.AllowTeamChangeOnTouch 属性,当玩家触摸它时,他们将改变队伍到 SpawnLocation 的团队伍。在这种情况下,只有第一个 Team 才应该有 Class.Team
注意,如果 SpawnLocation 在 Studio 中的 Workspace 添加了 SpawnLocation.Neutral 设置为 false 一个团队将被创建,相当于 SpawnLocation.TeamColor 如果它尚未存在
生成规则
当玩家重生时,有几个规则会适用于指定的 SpawnLocation:
- 当 SpawnLocation.Neutral 设置为 false 只有 Players 与 Player.TeamColor 匹配 1> Class.SpawnLocation.TeamColor1> 将在它上面重生
- 当 SpawnLocation.Neutral 设置为 true 任何玩家都可以在它上方生成,无论 SpawnLocation.TeamColor
- 如果有多个可用的生成地点Player,将随机选择一个
- 玩家将在 SpawnLocation 的不同位置生成,但当前, 他们仍然可以在不同位置上生成, 如果他们在不同位置上生成正确, 如果他们在不同位置上生成正确
还请参阅:
- 如果您想配置玩家重生的时间,请查看RespawnTime属性
代码示例
local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- position spawns
startSpawn.CFrame = CFrame.new(0, 0.5, 0)
team1Spawn.CFrame = CFrame.new(10, 0.5, 0)
team2Spawn.CFrame = CFrame.new(20, 0.5, 0)
team3Spawn.CFrame = CFrame.new(30, 0.5, 0)
概要
属性
允许一个 Player 加入队伍触摸 SpawnLocation 。设置为 true 时,如果一个 Player 角色与 2>Class.SpawnLocation2> 接触,其玩家的 5>Class.Player.TeamColor5> 将设置为 8>Class
在此 0>Class.SpawnLocation0> 生成的 3>Class.Player3> 角色的时间长度,以秒为单位,将被应用到 6>Class.ForceField6> 。如果持续时间为零,ForceField9> 将永远不会触发
设置是否启用 SpawnLocation 。禁用玩家无法在 SpawnLocation 生成,且允许团队更改触摸时间是否启用。
无论是否与特定团队关联,SpawnLocation 都是可以在它上生成的。这意味着,如果该属性设置为“Player”,或“Team”,任何2>Class.Player2> 或5>Class.Team5> 都可以在其上生成。
设置SpawnLocation 是否属于某个团队。如果SpawnLocation.Neutral属性是否为“Players”,只有1> Class.Player.TeamColor1> 与4> Class.SpawnLocation4> 相同的重生点队才能在该生成器中生成。
设置对象的整体形状。
确定是否是物理上移动不可的部件。
零件的组装角度的速度。
零件装配在世界空间中的中心。
零件的装配直线速度。
零件的装配总量。
对装置的根部分的引用。
确定零件的背面表面类型 (+Z 方向)。
确定零件底部面的表面类型(-Y 方向)。
确定零件的颜色。
确定世界上的 BasePart 的位置和方向。
确定零件是否会与其他零件碰撞。
确定是否在空间查询操作中考虑零件。
决定是否在 Touched 和 TouchEnded 事件触发部件。
是否或否决定零件是否投射阴影。
描述零件中心的位置在哪个世界位置。
描述零件碰撞群组的名称。
确定零件的颜色。
指示零件的当前物理属性。
确定零件的几个物理属性。
用于启用或禁用零件和组装件上的气动力。
Class.BasePart 的物理部分的 BasePart 。
在物理引擎的视角下,BasePart的实际物理大小。
确定零件前面的表面类型(-Z 方向)。
确定零件左面的表面类型(-X 方向)。
为 BasePart.Transparency 设置一个倍增器,该客户端只能看到本地客户端。
在 Studio 中选择零件。
描述零件的质量、密度和体积。
确定零件是否对其刚性身体的总质量或粒度有贡献。
确定零件的材质和默认物理属性。
Class.Material 的名称。
描述世界上部件的旋转。
指定零件的中心从其 CFrame 。
描述世界中部件的位置。
上次记录的物理更新时间。
确定零件反射天空盒子的程度。
描述允许通过“调整大小”方法描述的最小变更。
描述零件可以调整的面。
确定零件右侧的表面类型 (+X 方向)。
确定装配件的根部的主要规则。
三轴上的零件的旋转。
确定零件的尺寸 (长度、宽度、高度)。
确定零件的顶部面的表面类型 (+Y 方向)。
通过(反向)零件隐私度来确定零件的可见度。
方法
继承自BasePart的方法将角度冲击应用到装配件。
在装配的 center of mass 上应用脉冲。
将脉冲应用到指定位置的装配上。
返回零件是否可以相互碰撞。
检查您是否可以设置零件的网络所有权。
返回一个连接对象的零件表,通过任何类型的刚性关接头。
返回所有连接到此零件的关联或限制。
返回 Mass 属性的值。
返回当前玩家,这是网络的主人,或者在服务器的情况下为零。
如果游戏引擎自动决定网络所有者,返回 true。
返回零件组的基础部分。
返回包含所有 BasePart.CanCollide 真实零件的表。
返回该零件相对于此零件所给定位置的直线速度。
返回 true 如果对象连接到一个部件,它将在那里保持位置(例如 Class.BasePart.Anchored|Anchored 部件),否则返回 false。
就像使用 Studio 调整对象大小。
将给予的玩家作为网络所有者,为此和所有连接的部分。
让游戏引擎动态地决定谁将处理零件的物理(客户端或服务器之一)。
- IntersectAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
从零件和其他零件在给定数组列中交叉的几何图形中创建一个新的 IntersectOperation。
- SubtractAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
从零件中创建一个新的 UnionOperation ,减去指定数组列中零件所占的几何。
- UnionAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
从零件中创建一个新的 UnionOperation ,还包括在指定的数组列中占用位置的零件。
获得 PVInstance 的枢轴。
形成 PVInstance 与所有的后代 PVInstances ,使 pivot 现在位于指定的 CFrame 。
属性
AllowTeamChangeOnTouch
允许一个 Player 加入团队触摸 SpawnLocation 。当设置为真
当 SpawnLocation.Enabled 设置为 false 时,这将不会工作。
创建检查点
此功能通常用于在障碍赛或类似游戏中设置检查点。
代码示例
local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- position spawns
startSpawn.CFrame = CFrame.new(0, 0.5, 0)
team1Spawn.CFrame = CFrame.new(10, 0.5, 0)
team2Spawn.CFrame = CFrame.new(20, 0.5, 0)
team3Spawn.CFrame = CFrame.new(30, 0.5, 0)
Duration
在此 0>Class.SpawnLocation0> 生成的 3>Class.Player3> 角色的时间长度,以秒为单位,将被应用到 6>Class.ForceField6> 。如果持续时间为零,ForceField9> 将永远不会触发
此属性的默认值是 10 秒。
持续时间功能允许开发人员轻松为 Players 提供保护,这可能是玩家感到烦恼的一种体验。注意, ForceFields 只会保护用户免受 Explosions
代码示例
local spawnLocation = Instance.new("SpawnLocation")
spawnLocation.Anchored = true
spawnLocation.Size = Vector3.new(5, 1, 5)
spawnLocation.Neutral = true -- anyone can spawn here
spawnLocation.Duration = 20
spawnLocation.Parent = workspace
Enabled
设置是否启用 SpawnLocation 。当禁用玩家无法在 SpawnLocation 和 SpawnLocation.AllowTeamChangeOnTouch 功能性中生成时,该功能已禁用。
此属性提供最便利的方法来防止 Players 在生成时出生在重生点中。
注意,尽管使用 SpawnLocation.AllowTeamChangeOnTouch 在触摸时更改团队是禁用的,但使用 BasePart.Touched 的其他触摸事件仍然会发触发。
代码示例
local spawnLocation = Instance.new("SpawnLocation")
spawnLocation.Anchored = true
spawnLocation.Size = Vector3.new(5, 1, 5)
spawnLocation.Neutral = true -- anyone can spawn here
spawnLocation.Enabled = true
spawnLocation.Parent = workspace
local function onEnabledChanged()
spawnLocation.Transparency = spawnLocation.Enabled and 0 or 0.5
end
spawnLocation:GetPropertyChangedSignal("Enabled"):Connect(onEnabledChanged)
task.wait(5)
spawnLocation.Enabled = false -- transparency = 0.5
Neutral
无论是否与特定团队关联。这意味着 任何 Player 、任何 Team 的生成都可以在上面生成,如果这个属性设置为 true 。
如果 Neutral 设置为 false,只有其他玩家的 Player.TeamColor 与 SpawnLocation.TeamColor 相等才能使用 SpawnLocation 。
如果 SpawnLocation.AllowTeamChangeOnTouch 是 true Player.Neutral 将在与重生点器触摸时设置为此属性。
代码示例
local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- position spawns
startSpawn.CFrame = CFrame.new(0, 0.5, 0)
team1Spawn.CFrame = CFrame.new(10, 0.5, 0)
team2Spawn.CFrame = CFrame.new(20, 0.5, 0)
team3Spawn.CFrame = CFrame.new(30, 0.5, 0)
TeamColor
团队颜色属性设置团队 SpawnLocation 所属的团队。如果 SpawnLocation.Neutral 属性是 false,只有 Players 使用相同的 2>Class.Player.TeamColor2> 作为该重生点器的团队颜色才能在那里生成。
如果 SpawnLocation.AllowTeamChangeOnTouch 是 true Player.Neutral 将在与重生点器触摸时设置为此属性。
代码示例
local Teams = game:GetService("Teams")
-- create start team (AutoAssignable = true)
local startTeam = Instance.new("Team")
startTeam.Name = "Start"
startTeam.AutoAssignable = true
startTeam.TeamColor = BrickColor.new("White")
startTeam.Parent = Teams
-- create checkpoint teams (Autoassignable = false), ensuring all TeamColors are unique
local team1 = Instance.new("Team")
team1.Name = "Checkpoint 1"
team1.AutoAssignable = false
team1.TeamColor = BrickColor.new("Bright blue")
team1.Parent = Teams
local team2 = Instance.new("Team")
team2.Name = "Checkpoint 2"
team2.AutoAssignable = false
team2.TeamColor = BrickColor.new("Bright green")
team2.Parent = Teams
local team3 = Instance.new("Team")
team3.Name = "Checkpoint 2"
team3.AutoAssignable = false
team3.TeamColor = BrickColor.new("Bright red")
team3.Parent = Teams
-- create spawns
local startSpawn = Instance.new("SpawnLocation")
startSpawn.Anchored = true
startSpawn.Size = Vector3.new(5, 1, 5)
startSpawn.Neutral = false
startSpawn.AllowTeamChangeOnTouch = false
startSpawn.TeamColor = startTeam.TeamColor
startSpawn.BrickColor = startTeam.TeamColor
startSpawn.Parent = game.Workspace
local team1Spawn = Instance.new("SpawnLocation")
team1Spawn.Anchored = true
team1Spawn.Size = Vector3.new(5, 1, 5)
team1Spawn.Neutral = false
team1Spawn.AllowTeamChangeOnTouch = true
team1Spawn.TeamColor = team1.TeamColor
team1Spawn.BrickColor = team1.TeamColor
team1Spawn.Parent = game.Workspace
local team2Spawn = Instance.new("SpawnLocation")
team2Spawn.Anchored = true
team2Spawn.Size = Vector3.new(5, 1, 5)
team2Spawn.Neutral = false
team2Spawn.AllowTeamChangeOnTouch = true
team2Spawn.TeamColor = team2.TeamColor
team2Spawn.BrickColor = team2.TeamColor
team2Spawn.Parent = game.Workspace
local team3Spawn = Instance.new("SpawnLocation")
team3Spawn.Anchored = true
team3Spawn.Size = Vector3.new(5, 1, 5)
team3Spawn.Neutral = false
team3Spawn.AllowTeamChangeOnTouch = true
team3Spawn.TeamColor = team3.TeamColor
team3Spawn.BrickColor = team3.TeamColor
team3Spawn.Parent = game.Workspace
-- position spawns
startSpawn.CFrame = CFrame.new(0, 0.5, 0)
team1Spawn.CFrame = CFrame.new(10, 0.5, 0)
team2Spawn.CFrame = CFrame.new(20, 0.5, 0)
team3Spawn.CFrame = CFrame.new(30, 0.5, 0)