SpawnLocations, 或 "sponses" 確定死亡時 Player 重生在哪裡。他們可以設置允許特定玩家使用每個生成時間,使用 Teams 。他們也控制如何設置 ForceFields 對新重生玩家。
可以使用 SpawnLocations 作為檢查點,例如在障礙賽中,使用 SpawnLocation.AllowTeamChangeOnTouch 屬性,讓當玩家觸摸它時,他們會改變隊伍到 SpawnLocation 的隊團隊。在這個情況下,只有第一個
注意,如果 SpawnLocation 被添加到 Studio 的 Workspace 裡,並且 SpawnLocation.Neutral 設為 false ,則會創建一個與 SpawnLocation.TeamColor 無關的�
生成規則
玩家重生時會適用一些規則,以下是其中的一些:
- 當 SpawnLocation.Neutral 設為真的時,任何玩家都可以在它上方重新生成,不論是否設定 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 。當設為真時,如果 Player 角色與 1> Class.SpawnLocation1> 接觸,玩家的 4> Class.Player.Team
Class.ForceField 將在此 Player 生成的角色。如果時效為零,SpawnLocation 將永遠不會建立,並且會導致 1> Class.Instance.DescendantAdded1> 或 4>
設定是否啟用SpawnLocation。當無法啟用玩家時,無法在SpawnLocation中生成。當啟用"AllowTeamChangeOnTouch"功能時,則會禁用"AllowTeamChangeOnTouch"功能。
Class.SpawnLocation 與特定團隊有關或不關係。這意味著任何 Player 、任何 Team 的人都可以在上面重生,如果此屬性設為真。
設定 SpawnLocation 是否屬於某個團隊。如果 SpawnLocation.Neutral 屬性為 false,只有 Players 與同一 2>Class.Player.TeamColor2> 作為生成的 TeamColor 才能在那裡生成。
設定對物件的整體形狀。
是否確定零件是否可以按照物理學原理移動。
零件裝配的角度速度。
零件裝配在世界空間中的中心。
零件裝配的直線速度。
零件組裝的總量。
一個組裝根部分的引用。
決定零件背面的表面類型 (+Z 方向)。
決定零件底部面的表面類型 (-Y 方向)。
決定零件的顏色。
確定 BasePart 在世界中的位置和方向。
是否確定零件是否與其他零件碰撞。
確定要在空間查詢操作中檢視零件。
決定是否發生 Touched 和 TouchEnded 事件。
是否啟用或否啟用零件的暗影。
描述零件中心的位置在哪個世界位置。
描述零件碰撞群組的名稱。
決定零件的顏色。
指示零件的當前物理屬性。
確定零件的多個物理屬性。
用於啟用或解除零件和裝配件上的空力力量。
Class.BasePart 的物理部分的 BasePart。
BasePart 的實際物理尺寸,按照物理引擎的說明。
決定零件前面的表面類型 (-Z 方向)。
決定零件左面的表面類型 (-X 方向)。
決定對BasePart.Transparency的乘數,只對本地客戶端可見。
決定 Studio 中是否可選擇零件。
描述零件的大小,其密度和體積的產物。
確定零件是否對其剛身體的總質量或穩定性貢獻。
決定零件的材質和預設物理屬性。
Class.MaterialVariant 的名稱。
描述世界上零件的旋轉。
指定零件的中心點偏移值。
描述世界上零件的位置。
上次記錄物理更新的時間。
決定零件反射天空盒子的程度。
說明方法允許的最小尺寸變更。
描述零件可以重新尺寸的面。
決定零件右面的表面類型 (+X 方向)。
決定組裝件根部的主要規則。
三軸的旋轉度。
確定零件的尺寸 (長度、寬度、高度)。
決定零件上方面的表面類型 (+Y 方向)。
決定零件可以看到的程度(零件的反射)。
方法
方法 繼承自 BasePart對組裝件施加角度 impulse。
在裝配的 center of mass 上對裝配進行脈衝。
在指定位置對裝配進行脈衝。
返回零件是否能相互碰撞。
檢查您是否可以設置零件的網路擁有權。
返回任何類型的靈活組合節連接到對象的表。
返回連接到此零件的所有關聯零件或限制。
返回 Mass 屬性的值。
返回目前是網路擁有者的玩家,或是伺服器的情況下為零。
如果遊戲引擎自動決定網路擁有者,則返回 true。
返回零件組的零件。
返回與此零件交叉的所有 BasePart.CanCollide 個真實零件。
返回零件的組裝速度,與此零件相對的位置。
如果對象連接到一個會將其保留在位置的零件(例如Anchored 零件),則返回為真。
使用 Studio 調整大小工具的大小來變更對象的大小。
將指定的玩家設為網路所有者,這和所有連接的零件。
讓遊戲引擎動態決定誰會處理零件的物理學 (一個客戶或伺服器).
- IntersectAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
從零件和其他零件在指定的陣列中交織的 геометria中創建新的 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
Class.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
Class.ForceField 將在此 Player 生成的角色。如果時效為零,SpawnLocation 將永遠不會建立,並且會導致 1> Class.Instance.DescendantAdded1> 或 4>
此屬性的預設值為 10 秒。
保護時效功能可讓開發人員容易給 Players 防護從 "生成殺死" 可能造成的困擾玩家。注意, ForceFields 只會保護用戶免受
範例程式碼
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 和 1>Class.SpawnLocation.AllowTeamChangeOnTouch1> 功能中生成時,啟用 4>Class.SpawnLocation.AllowTeamChangeOnTouch4> 功能。
此屬性提供最便利的方法來防止 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 的任何位置重複。這意味著任何 Class.Player , 2>Class.Team2> 的重複生成都可以在它上重複,如果此屬性設為 true。
如果 Neutral 設為 false,只有 Player.TeamColor 與 SpawnLocation.TeamColor 相等的玩家才能使用 SpawnLocation。
如果 SpawnLocation.AllowTeamChangeOnTouch 是真的,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
Class.SpawnLocation 的屬性設定了 SpawnLocation.Neutral 屬性是否為團隊所屬。如果 Players 屬性是假,只有 1>Class.Player|Players1> 使用相同的 4>Class.Player.TeamColor4> 作為生成的團隊��
如果 SpawnLocation.AllowTeamChangeOnTouch 是真的,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)