SpawnLocation

Afficher les obsolètes

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.

Les emplacements d'apparition, ou « apparitions », déterminent où un Player réapparaît lorsqu'il meurt.Ils peuvent être configurés pour permettre à certains joueurs seulement d'utiliser chaque régénération, apparition, en utilisant Teams .Ils contrôlent également comment ForceFields sont configurés pour les nouveaux joueurs générés.

Les emplacements d'apparition peuvent être utilisés comme points de contrôle, comme dans un parcours d'obstacles, en utilisant la propriété SpawnLocation.AllowTeamChangeOnTouch, afin que lorsqu'un joueur le touche, il change d'équipe pour l'équipe de SpawnLocation.Dans ce cas, seule la première doit être réglée sur vrai, sinon les joueurs ne commenceront pas au premier point de contrôle.

Notez si un SpawnLocation est ajouté à la Workspace dans Studio avec SpawnLocation.Neutral réglé sur false, une équipe sera créée correspondant à SpawnLocation.TeamColor s'il n'existe pas déjà.Ce comportement ne se produit pas lorsque des spawns sont créés dans le jeu en utilisant un Script ou si les propriétés de SpawnLocation sont modifiées après avoir déjà été ajoutées.Il est recommandé que les développeurs configurent toujours leurs équipes manuellement et ne comptent pas sur ce comportement.

Génération de règles

Il y a plusieurs règles qui entrent en jeu pour un lieu d'apparition donné lorsqu'un joueur réapparaît :

  • Lorsque SpawnLocation.Neutral est réglé sur false uniquement Players avec Player.TeamColor correspondant à SpawnLocation.TeamColor réapparaîtra au-dessus
  • Lorsque SpawnLocation.Neutral est réglé sur vrai, n'importe quel joueur peut apparaître au-dessus d'elle indépendamment de SpawnLocation.TeamColor
  • Si plusieurs éclosions éligibles sont disponibles pour un Player, une éclosion aléatoire sera choisie
  • Les joueurs apparaîtront à différents endroits au-dessus d'un lieu d'apparition, mais actuellement, ils peuvent encore apparaître au-dessus les uns des autres si ils apparaissent immédiatement après l'un et l'autre

Voir aussi :

  • Si vous souhaitez configurer le temps qu'il faut pour qu'un joueur réapparaisse, consultez la propriété RespawnTime

Échantillons de code

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.

SpawnLocation Checkpoints

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)

Résumé

Propriétés

Propriétés hérités de PartPropriétés hérités de BasePart
  • Lecture parallèle

    Détermine si une partie est immobile par la physique.

  • Non répliqué
    Lecture parallèle

    La vitesse angulaire de l'assemblage de la pièce.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Le centre de masse de l'assemblage de la partie dans l'espace mondial.

  • Non répliqué
    Lecture parallèle

    La vitesse linéaire de l'assemblage de la pièce.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    La masse totale de l'assemblage de la partie.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Une référence à la partie racine de l'assemblage.

  • Lecture parallèle

    Détermine si la partie interagira physiquement avec la simulation audio, similaire à CastShadow pour l'éclairage.

  • Lecture parallèle

    Détermine le type de surface pour le dos d'une pièce.

  • Détermine le type de surface pour le côté inférieur d'une pièce.

  • Non répliqué
    Lecture parallèle

    Détermine la couleur d'une partie.

  • Lecture parallèle

    Détermine la position et l'orientation du BasePart dans le monde.

  • Lecture parallèle

    Détermine si une partie peut entrer en collision avec d'autres parties.

  • Lecture parallèle

    Détermine si la partie est prise en compte lors des opérations de requête spatiale.

  • Lecture parallèle

    Détermine si Touched et TouchEnded événements se déclenhent sur la partie.

  • Lecture parallèle

    Détermine si oui ou non une partie lance une ombre.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Décrit la position mondiale dans laquelle le centre de masse d'une partie est situé.

  • Non répliqué
    Lecture parallèle

    Détermine le nom du groupe de collision d'une partie.

  • Non répliqué
    Lecture parallèle

    Détermine la couleur d'une partie.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Indique les propriétés physiques actuelles de la pièce.

  • Détermine plusieurs propriétés physiques d'une partie.

  • Lecture parallèle

    Utilisé pour activer ou désactiver les forces aérodynamiques sur les parties et les assemblages.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Le CFrame de l'extensibilité physique du BasePart.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    La taille physique réelle du BasePart telle que perçue par le moteur de physique.

  • Lecture parallèle

    Détermine le type de surface pour le visage avant d'une partie.

  • Lecture parallèle

    Détermine le type de surface pour le côté gauche d'une pièce.

  • Caché
    Non répliqué
    Lecture parallèle

    Détermine un multiplicateur pour BasePart.Transparency qui n'est visible que pour le client local.

  • Lecture parallèle

    Détermine si une partie est sélectionnable dans Studio.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Décrit la masse de la partie, le produit de sa densité et de son volume.

  • Lecture parallèle

    Détermine si la partie contribue à la masse totale ou à l'inertie de son corps rigide.

  • Lecture parallèle

    Détermine la texture et les propriétés physiques par défaut d'une pièce.

  • Non répliqué
    Lecture parallèle

    Le nom de MaterialVariant.

  • Caché
    Non répliqué
    Lecture parallèle

    Décrit la rotation de la partie dans le monde.

  • Lecture parallèle

    Spécifie le décalage du pivot de la partie par rapport à son CFrame .

  • Caché
    Non répliqué
    Lecture parallèle

    Décrit la position de la partie dans le monde.

  • Caché
    Lecture uniquement
    Non répliqué
    Lecture parallèle

    Temps écoulé depuis la dernière mise à jour physique enregistrée.

  • Lecture parallèle

    Détermine à quel point une partie reflète la skybox.

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Décrit le plus petit changement de taille autorisé par la méthode Resize().

  • Lecture uniquement
    Non répliqué
    Lecture parallèle

    Décrit les visages sur lesquels une partie peut être redimensionnée.

  • Lecture parallèle

    Détermine le type de surface pour le côté droit d'une pièce.

  • Lecture parallèle

    La règle principale pour déterminer la partie racine d'une assemblée.

  • Non répliqué
    Lecture parallèle

    La rotation de la pièce en degrés pour les trois axes.

  • Non répliqué
    Lecture parallèle

    Détermine les dimensions d'une pièce (longueur, largeur, hauteur).

  • Lecture parallèle

    Détermine le type de surface pour le haut du visage d'une pièce.

  • Lecture parallèle

    Détermine à quel point une partie peut être vue à travers (l'inverse de l'opacité de la partie).

Propriétés hérités de PVInstance

Méthodes

Méthodes hérités de BasePartMéthodes hérités de PVInstance

Évènements

Évènements hérités de BasePart

Propriétés

AllowTeamChangeOnTouch

Lecture parallèle

Permet à un Player de rejoindre l'équipe en touchant le SpawnLocation.Lorsqu'il est défini sur vrai, si un caractère Player entre en contact avec le SpawnLocation, le Player.TeamColor du joueur sera défini sur SpawnLocation.TeamColor.Player.Neutral sera également réglé sur SpawnLocation.Neutral lors du contacter, ce qui signifie qu'un joueur peut également devenir neutre en touchant un lieu de production.

Cela ne fonctionnera pas lorsque SpawnLocation.Enabled est réglé sur false.

Faire des points de contrôle

Cette fonction est souvent utilisée pour créer des points de contrôle dans des courses d'obstacles ou des jeux similaires.

Échantillons de code

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.

SpawnLocation Checkpoints

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

Lecture parallèle

La durée, en secondes, pendant laquelle un ForceField sera appliqué à un Player personnage générant à cet endroit SpawnLocation .Si la durée est zéro, le ForceField n'est jamais créé et ne déclenchera pas les événements Instance.DescendantAdded ou Instance.ChildAdded.

Cette valeur par défaut de cette propriété est de 10 secondes.

La fonction de durée permet aux développeurs de donner facilement une protection Players contre le "spawn killing" qui peut être une expérience frustrante pour les joueurs.Note, ForceFields ne protégera les utilisateurs que des Explosions armes qui utilisent Humanoid:TakeDamage() pour infliger des dommages ou autrement vérifier un ForceField .

Échantillons de code

This sample will create a neutral SpawnLocation in the Workspace that'll give players spawning a ForceField for 20 seconds.

SpawnLocation ForceField

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

Lecture parallèle

Définit si le SpawnLocation est activé ou non. Lorsqu'il est désactivé, les joueurs ne peuvent pas apparaître dans le SpawnLocation et la fonctionnalité SpawnLocation.AllowTeamChangeOnTouch est désactivée.

Cette propriété fournit la façon la plus pratique d'empêcher Players de se générer à un point d'apparition.

Remarque, bien que le changement d'équipe au touch en utilisant SpawnLocation.AllowTeamChangeOnTouch soit désactivé lorsque Enabled est réglé sur false, d'autres événements touchés en utilisant BasePart.Touched seront toujours lancer.

Échantillons de code

The following sample will create a SpawnLocation in the Workspace that will become semi-transparent when it is disabled.

SpawnLocation Enabled

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

Lecture parallèle

Si oui ou non un spawn est affilié à une équipe spécifique.Cela signifie que tout Player , de tout Team , peut s'y générer si cette propriété est définie sur vrai.

Si Neutre est défini sur false, seuls les joueurs dont le Player.TeamColor est égal à SpawnLocation.TeamColor peuvent utiliser le SpawnLocation .

Si SpawnLocation.AllowTeamChangeOnTouch est vrai, Player.Neutral sera défini sur cette propriété lors du contact avec le régénération, apparition.

Échantillons de code

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.

SpawnLocation Checkpoints

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

Lecture parallèle

La propriété TeamColor définit à quelle équipe le SpawnLocation est affilié.Si la propriété SpawnLocation.Neutral est fausse, seul Players avec le même Player.TeamColor que la couleur d'équipe de la régénération, apparitionsera en mesure de s'y générer.

Si SpawnLocation.AllowTeamChangeOnTouch est vrai, Player.Neutral sera défini sur cette propriété lors du contact avec le régénération, apparition.

Échantillons de code

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.

SpawnLocation Checkpoints

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)

Méthodes

Évènements