- Home /
Object Not Recieving Damage
Ive created an Object that should act as a tower in a spacewars game, it attacks, looks at the target and aims properly and stuff, but it doesn't recieve damage for a reason, I've attached the following script on the object, whats really happening is, that the function OnCollisionEnter isnt even functioning, because the nothing is appearing on the Debug Log:
private int health=20;
void onCollisionEnter(Collision other) { if(other.gameObject.tag=="Bullet") { health-=5; Debug.Log(health.ToString(),gameObject); } }
// Use this for initialization void Start () {
}
// Update is called once per frame void Update () { if(health<=0) Destroy(gameObject);
}
}
Thanks for help.
Answer by Freaklegend · Nov 03, 2010 at 08:23 PM
ya and your point is? or ur just a troll?
That functions in unity are case sensitive, and that could be a reason that your code is not working.
Atnas is right, check your console to see it, one or more errors should appear.
@Bravini - No it shouldn't. It is perfectly fine to have a function called onCollisionEnter, it just doesn't get called when something enters the collider.
Answer by QueenMab051 · Nov 04, 2010 at 03:01 AM
Have you tried any of the Unity tutorials? I know at least one of them has a damage script you can check out.