GameObject.FindWithTag
Scripting > Runtime Classes > GameObject
GameObject.FindWithTag

static function FindWithTag (tag : string) : GameObject

Description

Returns one active GameObject tagged tag. Returns null if no GameObject was found.

Tags must be declared in the tag manager before using them.

// Instantiates respawnPrefab at the location
// of the game object with tag "Respawn"
var respawnPrefab : GameObject;
var respawn = GameObject.FindWithTag ("Respawn");
Instantiate (respawnPrefab, respawn.position, respawn.rotation);