How do i destroy a platform after collision with a quad?
I have a quad a child of my camera. the camera follow the player. the game is an infinite runner in 3D. I have a script to destroy the objects but it isn't working. All of my ground have the tag "Ground" and are not rigid bodies. they are prefabs that spawn in and have a box collider. The quad has a mesh collider, no tag, no rigidbody.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class DestroyerScript : MonoBehaviour {
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Player")
{
SceneManager.LoadScene ("lose", LoadSceneMode.Single);
return;
}
if (other.gameObject.tag == "Ground")
{
Destroy (other.gameObject.transform.parent.gameObject);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Destroying prefabs breaking scripting for other prefabs 0 Answers
Destroying enemy only partially works 0 Answers
Destroy gameobjects several times in a scene. Also destroy other instances of that gameobject. 2 Answers
One script for multiple enemy objects problem 2 Answers
Instantiated bullet wont destroy 1 Answer