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 Toy · Feb 17, 2012 at 02:22 AM · heightdeath

Script to detect a death fall

Hi there here is my problem. I imported a skecth up map in unity. This map is one big component. That map has sevral big bloc from different heights. I want to script in c# something that would detect if my hero fall from more than 10 meters he dies instantly. I really don't know where to strart of and how to do it.

Thanx

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 shaneapp · Feb 17, 2012 at 02:45 AM 0
Share

Depending on the situation, its often a good idea to place either 1 large invisible box, that when collided with will cause 'death', or place several boxes in addition. Otherwise you will need to keep track of all possible fall locations and calculate distance - 10 meters, which is not a catch-all solution.

avatar image Toy · Feb 17, 2012 at 03:14 AM 0
Share

Yeah thats the point I just cant keep track of all possible fall locations. $$anonymous$$y map is kind of an open world.

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by jessee03 · Feb 17, 2012 at 02:48 AM

once your character is falling start a timer and if it exceeds that time and is still falling then activate death.

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 rabbitfang · Feb 17, 2012 at 03:28 AM 0
Share

He asked from a specified height, not for falling for so long of a time. While you can use a function of max distance, gravity and time, it is not always guaranteed to be accurate.

avatar image jessee03 · Feb 17, 2012 at 03:33 AM 0
Share

Well I was trying to say calculate how long in would take to fall 10 meters... Then if it exceeds that then kill the player.

avatar image rabbitfang · Feb 17, 2012 at 03:40 AM 0
Share

I know. But it can be inaccurate if there are extra forces involved (especially drag from the 'air').

avatar image
0

Answer by rabbitfang · Feb 17, 2012 at 03:34 AM

An easier thing to do would be to use a maximum fall velocity threshold. Every frame you would check to see if the velocity would be over this and then if it is, set a flag that tells the script to 'kill' the object on collision with the ground.

If you did want to do it with distance, every frame, check the Y (vertical) velocity and if it is less than (moving down) a really small negative value (to account for inaccuracies with floating point values) (say < -0.01f), set the current Y value in a starting height variable. When the collision Y value (where they hit the ground) is greater than the allowed fall distance (10 meters in this case), kill the hero.

I would recommend using acceleration (change of velocity between frames) as that gives the most realistic simulation of impact damage (from a fall, for instance) (it is the stopping that kills you, not the fall).

There are issues involved with using a time or distance approach because in theory, if you fall 100 meters in 24 hours (falling over that entire interval but moving really slowly), both of those methods would most likely kill you but it would be incredibly unrealistic. If you ever have upward forces applied to your hero (for example, from knockback from gunfire, or drag from the 'air'), then you should not use time or distance methods.

P.S. Sketch models are known to not be very efficient when it comes to using them as a mesh for a model. They are not optimized when exported.

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

8 People are following this question.

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

Related Questions

Character disappears when dies. 3 Answers

AI Awareness 2 Answers

Death script problem 2 Answers

Death when a character hits the ground from a certain height 0 Answers

Death on impact with water 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