重生位置或「重生」決定死亡時 Player 重生在哪裡。它們可以配置為只允許特定玩家使用每個重生點,使用 Teams 。他們也控制如何 ForceFields 為新生成的玩家設置。
重生位置可用於檢查點,例如在障礙賽中,使用 SpawnLocation.AllowTeamChangeOnTouch 屬性,當玩家觸碰它們時,他們將更換隊伍到重生位置的團隊。在這種情況下,只有第一個 應該設為真實,否則玩家將無法在第一個檢查點開始。
注意,如果在 Studio 中添加了 SpawnLocation,並將 設為 false,團隊將會創建相對應的 如果尚未存在。當在遊戲中使用 Script 生成時,或已添加 SpawnLocation 的屬性後變更時,此行為不會發生。建議開發人員始終手動設置團隊,而不要依靠此行為。
生成規則
當玩家重生時,有幾個規則會在給定的 SpawnLocation 中發揮作用:
- 當 SpawnLocation.Neutral 設為真實時,任何玩家都可以在它上方生成,無論 SpawnLocation.TeamColor
- 如果有多個符合條件的生成可用於 Player,將隨機選擇其中一個
- 玩家會在重生位置上重生,但目前,如果他們重生後立即重生,他們仍可能重生在一個上方或另一個上方
也見:
- 如果您想配置玩家重生所需的時間,請查看 RespawnTime 屬性
範例程式碼
This sample demonstrates how SpawnLocations can be used to make a checkpoint system. Typically this would be done Studio and not in Lua, but this example serves as a comprehensive example of what Team and SpawnLocation properties need to be used to achieve this setup.
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 即可加入。當設為真實時,如果Player角色與SpawnLocation接觸,玩家的Player.TeamColor將被設為SpawnLocation.TeamColor。
在 ForceField 秒內,應用到此 Player 生成角色的 SpawnLocation 時間長度,將對該角色產生影響。如果持續時間為零,ForceField 將永遠不會被創建,並且不會觸發 Instance.DescendantAdded 或 Instance.ChildAdded 事件。
設置是否啟用 SpawnLocation 。當停用玩家時,無法在 SpawnLocation 生成,並且「允許團隊變更在觸摸時」功能已停用。
是否一個 SpawnLocation 是否與特定團隊有關。這意味著任何 Player , 任何 Team , 如果此屬性設為真實,都可以在上面生成,如果此屬性設為真實。
設定 SpawnLocation 是哪個團隊所屬。如果 SpawnLocation.Neutral 屬性為假,只有 Players 與生成的團隊顏色相同的 Player.TeamColor 才能在那裡生成。
設定物件的整體形狀。
決定零件是否因物理學而無法移動。
零件裝配的角速度。
零件在世界空間的質量中心。
零件裝配的線速度。
零件裝配的總重量。
指向裝配的根部分。
決定零件後面的表面類型 (+Z方向)。
決定零件底面的表面類型(-Y方向)。
決定零件的顏色。
決定世界中 BasePart 的位置和方向。
決定零件是否可能與其他零件碰撞。
決定零件在空間查詢操作期間是否被考慮。
決定是否 Touched 和 TouchEnded 事件在零件上發射。
決定零件是否投射陰影。
描述零件的重心位置在哪裡。
描述零件衝突群組的名稱。
決定零件的顏色。
指示零件目前的物理特性。
決定零件的多個物理特性。
用於啟用或禁用零件和裝配的空氣動力。
物理引擎所看到的 BasePart 實際尺寸。
決定零件前面的表面類型(-Z方向)。
決定零件左面的表面類型(-X方向)。
決定只對本地客戶可見的乘數 BasePart.Transparency 。
決定零件是否可在 Studio 中選擇。
描述零件的質量、密度和體積的產品。
決定零件是否會對其剛性身體的總質量或慣性有貢獻。
決定零件的紋理和預設物理特性。
MaterialVariant 的名稱。
描述世界中零件的旋轉。
指定零件的軸偏移來自其 CFrame 。
描述零件在世界上的位置。
上次記錄物理更新的時間。
決定零件是否反映了天空盒。
描述縮放方法可允許的最小尺寸變更。
描述可以縮放零件的面。
決定零件右面的表面類型 (+X 方向)。
決定組裝根部分的主要規則。
零件在三軸上的旋轉度。
決定零件的尺寸(長度、寬度、高度)。
決定零件頂部面的表面類型 (+Y 方向)。
決定零件能被看到多少(與零件隱形度相反)。
方法
方法 繼承自 BasePart對裝配應用角度脈沖。
在裝配的 center of mass 應用脈沖到裝配。
在指定位置應用脈沖到裝配。
返回零件是否可以相互碰撞。
檢查您是否可以設置零件的網絡所有權。
返回包含任何種類剛性聯組合的對象與零件的表。
返回連接到此零件的所有關節或限制。
返回 Mass 屬性的值。
返回這部分網絡所有者的當前玩家,或在伺服器的情況下返回 nil。
如果遊戲引擎自動決定此部分的網絡所有者,返回真值。
返回零件組合的基本零件。
返回包含這個部分交叉的所有 BasePart.CanCollide 真實零件的表。
返回零件在指定位置相對於此零件的線速度。
如果對象連接到會將其保持在位置的零件(例如 Anchored 零件),則返回真值;否則返回假值。
以相同於使用 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 的軸心。
將 以及所有其子孫 轉換為指定的 位置,使旋轉點現在位於指定的 位置。
屬性
AllowTeamChangeOnTouch
允許一個 Player 加入團隊,觸碰 SpawnLocation 即可加入。當設為真實時,如果Player角色與SpawnLocation接觸,玩家的Player.TeamColor將被設為SpawnLocation.TeamColor。Player.Neutral 也會在聯聯絡時設為 SpawnLocation.Neutral,這意味著玩家也可以通過觸碰生成位置變得中立。
當 SpawnLocation.Enabled 設為 false 時,此功能將無法運作。
製作檢查點
此功能通常用於在障礙賽或類似遊戲中創建檢查點。
範例程式碼
This sample demonstrates how SpawnLocations can be used to make a checkpoint system. Typically this would be done Studio and not in Lua, but this example serves as a comprehensive example of what Team and SpawnLocation properties need to be used to achieve this setup.
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
在 ForceField 秒內,應用到此 Player 生成角色的 SpawnLocation 時間長度,將對該角色產生影響。如果持續時間為零,ForceField 將永遠不會被創建,並且不會觸發 Instance.DescendantAdded 或 Instance.ChildAdded 事件。
此特性的預設值為 10 秒。
持續時間功能讓開發人員可以輕鬆提供 Players 保護,這可能是玩家感到挫折的經驗。注意, 只會保護用戶免受 和使用 來造成傷害或其他檢查的武器。
範例程式碼
This sample will create a neutral SpawnLocation in the Workspace that'll give players spawning a ForceField for 20 seconds.
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 的其他觸摸事件仍會發觸發。
範例程式碼
The following sample will create a SpawnLocation in the Workspace that will become semi-transparent when it is disabled.
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 , 如果此屬性設為真實, 都可以在上面生成, 如果此屬性設為真實。
如果中立設為 false,只有等於 的玩家才能使用 。
如果 SpawnLocation.AllowTeamChangeOnTouch 是真的,Player.Neutral 將在與生成器聯繫時設置為此屬性。
範例程式碼
This sample demonstrates how SpawnLocations can be used to make a checkpoint system. Typically this would be done Studio and not in Lua, but this example serves as a comprehensive example of what Team and SpawnLocation properties need to be used to achieve this setup.
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 屬性為假,只有 Players 與生成的團隊顏色相同的 Player.TeamColor 才能在那裡生成。
如果 SpawnLocation.AllowTeamChangeOnTouch 是真的,Player.Neutral 將在與生成器聯繫時設置為此屬性。
範例程式碼
This sample demonstrates how SpawnLocations can be used to make a checkpoint system. Typically this would be done Studio and not in Lua, but this example serves as a comprehensive example of what Team and SpawnLocation properties need to be used to achieve this setup.
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)