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
0
Question by rainbowcore · Mar 31, 2013 at 05:42 PM · damagehpfps-controllerhealth

Adding fall damage with the default FPSWalker

I need to add fall damage to my game and I can't use the FPSWalkerEnhanced script because I have already built everything else around the default FPS Controller. Is there any way in doing so?

Comment
Add comment · Show 2
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 AlucardJay · Apr 01, 2013 at 06:39 AM 0
Share

Start by looking at the isGrounded variable. Watch if this remains false for a long period of time, then consider calculating an amount of damage to apply to the character once this becomes true again. You will need to do some checks that the player is in fact falling rather jumping, so start calculating damage to apply after you know how long it takes to finish a reasonable jump, or keep track of the movement direction of the character and calculate damage if you know its falling, etc etc.

avatar image -GenericPath- · Aug 31, 2013 at 01:54 PM 0
Share

adding onto what alucardj said, you should also add a default amount you can take so if you fall only a short distance you dont take damage.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by luckruns0ut · Aug 31, 2013 at 04:26 PM

I would simply check whether the player's velocity has dramatically changed since the last frame (or whenever), and if it has, apply damage according to the velocity change. You could also use this to have realistic velocity impacts if that interests you... Such as a car crash impacting health.

If something is falling, at say vec(0,-50,0) velocity at one frame, and then in the next it is at vec(0,0,0), that means they have fallen and then hit something because they have came to a sudden halt. You could use that difference to scale your health damage, or check if the distance is above a certain value to make it so that you don't get damaged by any changes above 10, for example.

There are of course simpler ways to do it, but I'd do it this way so that I could easily scale damage accordingly, rather than specifying exact fall lengths for each amount of damage you can take.

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

12 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

Related Questions

how do i make a script that calculate how much damage did i loss 1 Answer

For loop on collision (two hit kill) 2 Answers

Falling Damage 1 Answer

FireBall script 1 Answer

Enemy health drops but not if first enemy lives, how do i change that? 1 Answer


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