- Home /
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#.
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.
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.
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 ?
Answer by Berenger · May 11, 2012 at 03:46 PM
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.
Thank you you gave me something to look at and I managed to figure most of it out from there.