I'm very new to programming and game design, so I appreciate any help thrown my way.
In designing a "Pong" style game, I'm trying to destroy the ball object after a player scores, then instantiate it again in the center of the screen, making it wait 3 seconds before moving. My code for this portion of the ball script looks like this:
if((col.gameObject.name == "LeftGoal") || (col.gameObject.name == "RightGoal"))
{ Destroy(gameObject);
Rigidbody2D clone;
clone = Instantiate(rigidBody, transform.position = 0,0) as Rigidbody2D;
clone.velocity = transform.TransformDirection(Vector2.right * speed);
}
Thank you in advance!
↧