- Home /
What is wrong with my script?
When I made this script I get an error: Assets/Scripts/destroyer.js(6,11): BCE0023: No appropriate version of 'UnityEngine.Object.Destroy' for the argument list '(System.Type)' was found.
Here is my script:
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.name == "Bullet"){
Destroy (GameObject);
}
}
Don't use a capital G when referenceing gameObject in Destroy. That's what OrangeLightning is saying. Just change Destroy(GameObject) to Destroy(gameObject);
function OnCollisionEnter(theCollision : Collision)
{
if(theCollision.gameObject.name == "Bullet")
{
Destroy (gameObject);
}
}
thanks but $$anonymous$$y script is not working, not an error but it just not working! i attached it to a cube and want it to dissapear when it touches my bullets, why is this not working?
Go watch all of these...
http://walkerboystudio.com/html/unity_course_lab_2.html
They're free vid tutorials.
How fast is your bullet moving? Is the bullet a Rigidbody? If so set its collision detection to Continuous Dynamic. Otherwise you may need to look into Unity Raycast
Thank you for the vote up sir, I've done the same for you.