- Home /
Know if there is Collisions on my boxCollider
Hi all,
I would like to know if there is a collision on my boxCollider.
I send an object on a gameObject (zombie) and i would like to know when my object enter in collision. When it collides, i would like to destroy my gameObject (zombie)
Here is my script
using UnityEngine;
using System.Collections;
public class zombie : MonoBehaviour {
BoxCollider boxCollider;
// Use this for initialization
void Start () {
boxCollider = GetComponent <BoxCollider> ();
}
// Update is called once per frame
void Update () {
if (boxCollider.isTrigger == true) {
Destroy(this);
}
}
}
I have a rigidbody too on my zombie
Thank you for your help
Answer by Jeff-Kesselman · Nov 17, 2014 at 09:08 PM
Thats not even close to how colliders work.
Please read the documentation before asking for help:
http://docs.unity3d.com/Manual/CollidersOverview.html
If you have a few dollars to spend it would also save you a lot of time to get and work Goldstone's book: http://www.amazon.com/Development-Essentials-Community-Experience-Distilled/dp/1849691444
Hmm, in addition to what jeff is stating, please check out the roll-a-ball tutorial, this will cover what you're looking for. Then hit up the whole learning section and get some unity love.
Your answer
Follow this Question
Related Questions
Question about collision 2 Answers
Check different collisions 1 Answer
Distribute terrain in zones 3 Answers
Help in solving mistake in my code 1 Answer
My Unity Collision Wont Trigger Even with Rigidbody Added 2 Answers