How can i spawn a prefab into the game when a specific even happens?
Try this :
var prefabToSpawn : GameObject;
var spawnLocation : Vector3;
function RunEvent () {
Instantiate(prefabToSpawn, spawnLocation, Quaternion.identity);
}
Then simply run the function at the desired time.
Like @Eric5h5 stated, Instantiate is what you will need. Heres an example using a trigger. When the Player enters the trigger we spawn ‘somePrefab’ at the players position and rotation.
public var somePrefab:Transform;
function OnTriggerEnter(other:Collider)
{
if(other.CompareTag("Player"))
{
Instantiate(somePrefab,other.transform.position,other.transform.rotation);
}
}