Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Error CS0029 - Trying to destroy an object and then instantiate it again?

$
0
0
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!

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>