- Home /
Question by
joeeydubu · Jun 30, 2017 at 11:18 AM ·
collisiondestroycollision detectiononcollisionenter
Help with collisions and destroy please
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 ();
}
}
Comment
Answer by joeeydubu · Jul 02, 2017 at 10:39 AM
I just don't know why the destroy doesn't destroy the old ones then creates the new ones?
Your answer
Follow this Question
Related Questions
Smooth movement for the block upon player collision,Smooth box movement 0 Answers
Collisions with Grabbable Items 0 Answers
OnCollisionEnter being called without the colliders actually colliding 1 Answer
Collision detection when no collision happens,OnCollision is called without a collision 1 Answer
Colliders Events 1 Answer