Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Cence99 · Jun 09, 2013 at 05:59 PM · c#damageclothing

Armour / Damage System RPG-like?

Hi all!

I'm currently developing a 3rd person zombie shooter and would like to implement some kind of Clothing / Armour System to the player character.

I know how to put on & put off clothes, but not how for example any Roleplaying-Game is handling it with "the better the armour, the more damage will be absorbed!".

If I damage the player, I just do: "health -= damage;"

Which value do I need to substract from the damage when for example the Helmet has 20 defense points and the T-Shirt 15?

I don't think World of Warcraft is then substracting (20 + 15) from the damagevalue!

Thanks for all your answers!

Mike

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by InfiniBuzz · Jun 09, 2013 at 06:30 PM

Hi

there are a lot of ways to do this. I assume that you have a script for your player with a method that takes damage. Now you can add properties for things like armour. To calculate this it is depending on how you want your clothing take effect. To give you a very basic example you could do something like this

 damage = hitForce / currentArmor

Where damage is the value you will substract form the players health, hitForce is the force (damage) the enemy is hitting the player with and in currentArmor you sum up your armor values (helmet, t-shirt) (make sure currentArmor is at a minimum of 1, thanks scribe! )

basically there is no limitation to make this more complex if you want to have many types of armor, add poisoning or armour levelling etc.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Scribe · Jun 09, 2013 at 06:34 PM 1
Share

Good answer,

The only thing I'd add is to make sure currentArmor is clamped at a $$anonymous$$imum of 1 unless you want to take infinite damage when you have no armour!

+1

avatar image InfiniBuzz · Jun 09, 2013 at 06:36 PM 0
Share

good point thank you :) you could use this for some sort of poisoning, but it should never be 0 of course

avatar image Cence99 · Jun 11, 2013 at 12:50 PM 0
Share

Thanks, this simple calculation actually does the trick :)

avatar image
0

Answer by BlackWingsCorp · Jun 09, 2013 at 06:33 PM

hmmm... you can try something like this: public class DefenseSystem : MonoBehaviour{ public static float defense; public static bool isEquip;

     void Start(){
     defense = 0;
     isEquip = false;
     }
     
     void Update(){
     if(isEquip && isDamaged){//isDamaged is a static bool from the damaging script and damage is a static float value
     health -= defense - damage; //make sure health cannot reach higher then it's max value 
     }
     if(isDamaged && health == maxhealth)//if the damage was completly negated
     health -=1;//optional 
     }
 }
 }
 }

I hope this helps. Tell me how it works

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Multiple Cars not working 1 Answer

Melee-hits being recognized too often 1 Answer

Flash player when taking damage 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges