I need an object to appear as player walks into a trigger. So basicly I am asking for just one line of a script to make an object materialize in front of a player and then to be destroyed. Here is a reference to what I want to achieve.
public var AnObject : GameObject;
function OnTriggerEnter(other : Collider){
if(other.gameObject.name == "Player"){
------------------------????
yield WaitForSeconds(3);
GameObject.Destroy(AnObject);
}
}
Set the renderer.enabled to false in the inspector, then you can do: renderer.enabled = true;
– robertbuHere is the script. Shows no errors. However doesn't work. #pragma strict public var AmbienceCrate : GameObject; function Awake (AmbienceCrate) { renderer.enabled = false; } function OnTriggerEnter(other : Collider){ if(other.gameObject.name == "Player"){ renderer.enabled = true; yield WaitForSeconds(3); GameObject.Destroy(AmbienceCrate); } }
– 0_osmile0_o