DAMAGE - Programming Logic Question

Simular to Multiplayer FPS, you as a character, administer and receive damage from several weapon types and a plethora of game functionalities.

Im new to programming and would like to set up a way to take health away from myself when damaged, as well as other players when they are damaged.

  1. Do I write the script to deal damage on each bullet?

  2. Do I write the script on the character for… when hit by bullet type?

  3. Or do I create an empty object, then write a script (or function if my terminology is correct) to call; whenever the bullet reaches an end point?

Which would be the best case, and which object do I put the Call Function on if its number 3?

Thanks All!

1 Answer

1

Look into ray casting small, fast objects.

Everything Depends. There are too many ways to list on how you could take damage. You'll probably want to "send message" on collision and don't require a receiver. If what you hit knows what to do with "ApplyDamage" (a function your players might have) the object will take care of things from there, and your ray cast or bullet will be done or destroyed.

Edit: "ApplyDamage" is a function I use and not one built into Unity.

Thank you for the reply! Ok, so your "ApplyDamage" method has all of its functionality in it? This method is placed on the character? For instance, (pseudo / logic) Players script "ApplyDamage" if when whatev, hit by, this that or the other do x damage if when whatev, hit by, this that or the other do n damage and so on.. somthing to that affect? Please forgive my terminology totally learning my way through it. 1 hour per line of code haha :)

–