- Home /
problem with Destroy Function!!
Hi, Im Making An Explotion That Makes An Invisble Sphere For 0.1 Seconds And Destroys Everything That Touches It. It Says:
Assets/Standard Assets/Scripts/Game/explotion.js(16,16): BCE0023: No appropriate version of 'UnityEngine.Object.Destroy' for the argument list '(UnityEngine.ControllerColliderHit)' was found.
What is the problem? Code:
function Start () { print ("Explode!!"); }
function OnControllerColliderHit(hit:ControllerColliderHit) { if(hit.gameObject.tag == "Block" || hit.gameObject.tag == "qsand") { // dead = true; // lifeSystem.LIVES--; // if(lifeSystem.LIVES==0){ // lifeSystem.LIVES = 3; // print ("Game over"); // } Destroy(hit); } }
Edit: Ok I Changed hit to hit.gameObject But It Does Not Destroy Them! Edit: Now Fixed Ok.
do you have a controller collider on the object or just a regular collider?
Answer by Maarten · Mar 29, 2011 at 07:15 PM
Shouldnt you do the following:
Destroy(hit.gameObject);
it solves the error thanks, BUT IT DOES NOT DESTROY ANY OBJECTS
Are you sure that it even gets to the function call? If you havnt got a controller on it, the collider function will not trigger.
Please put a debug.log before the destroy statement to see if it gets triggered.
Answer by poncho · Apr 04, 2011 at 05:49 PM
you could try these
DestroyObject(GameObject.Find(hit.gameObject.name));
DestroyObject(hit.gameObject);
Destroy(GameObject.Find(hit.gameObject.name));
Destroy(hit.gameObject);
check the one that works to you