How do I destroy my Spawned Object, if does not toach anything?
Hi I am pretty new to Unity and have the Problem that I cant destroy my spawned object if they are not toaching my Ground. I spawning random Traps and want them be only On my Ground. Her is my SCript attached to my trap Prefab which gets Spawned:
using UnityEngine; using System.Collections;
public class Rotator : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 ( 0, 0, 100) * Time.deltaTime);
}
//public static bool IsTouchingLayers(Collider2D other)
void OnCollisionExit2D (Collision2D other)
{
if (other.gameObject.tag == "Ground")
{
gameObject.SetActive (false);
}
}
}
What am I doing wrong? (Its probably a noobie question) :)
Comment
Your answer
Follow this Question
Related Questions
How can I animate my 3D object without affecting the physics? 0 Answers
C# Lerping Problem 0 Answers
Particle Systems slowing game down too much. 0 Answers
Sonic Style Rail Grinding 1 Answer
Physics Question 0 Answers