Question by
Ozzy0 · May 22, 2017 at 09:48 PM ·
instantiatedestroyrespawn
How to spawn an object after destroy?,
How to spawn the GameObject Star after the Ball destroy the Star AND hit the ground? My code looks like this: public class BallReset : MonoBehaviour { public GameObject Star; Rigidbody rb;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
transform.position = new Vector3(-0.105f, 1.505f, -1.603f);
rb.isKinematic = true;
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
}
if (collision.gameObject.CompareTag("Colectible"))
{
Destroy(Star);
}
}
private void Respawn()
{
rb = null;
Instantiate (Star);
}
},
Comment