okay so I am trying to make a game where every time the ball hits the paddle it deletes the old platforms and then spawns new ones, I just can’t seem to figure it out can someone please help me heres my code for the 2 scripts!
PLATFORM SCRIPT
public void SpawnLeftPlatform() {
if (gameObject.tag == "LeftPlatform") {
transform.position = new Vector2 (xMin, Random.Range (yMin, yMax));
}
}
public void SpawnRightPlatform() {
if(gameObject.tag == "RightPlatform") {
transform.position = new Vector2 (xMax, Random.Range (yMin, yMax));
}
}
public void DestroyPlatforms() {
Destroy (gameObject);
}
BALL SCRIPT
void OnCollisionEnter2D(Collision2D coll) {
if (coll.transform.tag == "Paddle") {
platformScript.SpawnLeftFan ();
platformScript.SpawnRightFan ();
platformScript.DestroyFans ();
}
}