x


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.

more ▼

asked Nov 03 '10 at 07:32 PM

Freaklegend gravatar image

Freaklegend
1 1 1 3

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

It is called OnCollisionEnter

more ▼

answered Nov 03 '10 at 07:38 PM

Atnas1010 gravatar image

Atnas1010
1.1k 6 10 26

(comments are locked)
10|3000 characters needed characters left

Have you tried any of the Unity tutorials? I know at least one of them has a damage script you can check out.

more ▼

answered Nov 04 '10 at 03:01 AM

QueenMab051 gravatar image

QueenMab051
3 1 2 6

(comments are locked)
10|3000 characters needed characters left

ya and your point is? or ur just a troll?

more ▼

answered Nov 03 '10 at 08:23 PM

Freaklegend gravatar image

Freaklegend
1 1 1 3

That functions in unity are case sensitive, and that could be a reason that your code is not working.

Nov 03 '10 at 09:03 PM Atnas1010

Atnas is right, check your console to see it, one or more errors should appear.

Nov 03 '10 at 10:30 PM Bravini

@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.

Nov 03 '10 at 10:43 PM Atnas1010
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x653
x383
x248
x21
x11

asked: Nov 03 '10 at 07:32 PM

Seen: 558 times

Last Updated: Nov 03 '10 at 07:46 PM