x


Damage on collision

Hi I am looking for a script that will cause a variable amount of damage to the player or enemy when they collide with an object. It needs to be done in C#.

more ▼

asked May 11 '12 at 11:57 AM

GoryAssassin gravatar image

GoryAssassin
15 2 3

This isn't a recruitment board. If you want to hire a programmer for a single, simple task, I would recommend asking around in the forums. Otherwise, search the internet or look through the Asset Store- there are quite a few good things there that do what you need.

However, don't expect people to just write your games for you. I'm happy to help you with your code, but you need to put some effort in yourself- otherwise I'm doing all the work myself, and I start to question the wisdom of my altruism.

May 11 '12 at 12:01 PM syclamoth

I agree and disagree with you sycla. You are saying that you will not give him the script, as to when someone asks how to do this you give it to them. Wouldn't he be learning by example? Say study off of this and use // to help him. I can see your a former. Not a very good one if your like this.

May 11 '12 at 02:31 PM maroonrs2

Give a man code, he will eat tonight. Teach the man to code himself, he'll have food all his life. Confusing metaphore isn't it ?

May 11 '12 at 03:47 PM Berenger
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The first thing you need is to detect the collision. This is achieved by attaching a script to the characters that implements the function OnTrigger... or OnCollision...

Then, you will probably need to make sure the collider can cause damage by checking it's tag. The ground can't do damage for instance (I suppose).

Finally, you need a script taking care of the damage. It will probably have a variable health or as such.

If you wonder why I don't give you the code right away, see syclamoth's comment.

more ▼

answered May 11 '12 at 03:46 PM

Berenger gravatar image

Berenger
11k 12 19 53

Thank you you gave me something to look at and I managed to figure most of it out from there.

May 12 '12 at 08:04 AM GoryAssassin
(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:

x2499
x132

asked: May 11 '12 at 11:57 AM

Seen: 492 times

Last Updated: May 12 '12 at 08:04 AM