I need to make a Sphere appear 15 seconds after the FPSController has collided with a Cube and then make the Cube disappear after 30 seconds.
Ask if you need any specific details or clarifications. My english isn't the best sorry. I am using C#.
Comment
Answer by OncaLupe · Nov 27, 2015 at 07:16 PM
public GameObject prefabSphere;
void OnCollisionEnter(Collision other)
{
if(other.gameObject.CompareTag("Player"))
{
StartCoroutine("SpawnAndDie");
}
}
IEnumerator SpawnAndDie()
{
yield return new WaitForSeconds(15f);
Instantiate(prefabSphere);
yield return new WaitForSeconds(15f);
Destroy(gameObject);
}
Really basic, but should get you started. http://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html
Your answer
Follow this Question
Related Questions
creating a Breakout game in unity3d c#-bricks wont get destroyed 0 Answers
how do i collide and kill the enemy while pressing space Unity 5 C# 2 Answers
Game Objects wont appear after restart 0 Answers
Player falls through destroy collider 1 Answer
Instantiate and destroy an object with the same key 1 Answer