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 /
This question was closed Jul 30, 2013 at 01:32 AM by Drshk7 for the following reason:

The question is answered, right answer was accepted

avatar image
-4
Question by Drshk7 · Jul 15, 2013 at 03:58 AM · physicsrigidbodydeathkill

G-Mod like physics that kill?

So I'm currently trying to make it so that when parts of my collapsible buildings fall down, it kills the player. How can I do that? EXAMPLE script strongly suggested.

EDIT : NO ONCOLLIDERENTER!!! ONLY MASSIVE WEIGHT AND STRONG FALLING RIGID BODIES.

EDIT 2 : IM SORRY I MEANT I DIDNT WANT TO DAMAGE PLAYER WHEN ONCOLLIDERENTER. Sorry. :P

EDIT 3 : When I said EXAMPLE script I meant something to start me, not a full script. People hate people for that now??? T.T

Comment
Add comment · Show 3
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 EHogger · Jul 15, 2013 at 08:39 AM 0
Share

A collision event is what you need, so I don't know why you're discounting it. You can check the mass and velocity of the rigidbody to decide what happens.

avatar image creighcl · Jul 16, 2013 at 12:49 AM 0
Share

you want to destroy a game object (or do damage, maybe?) when debris is hitting the player, but you don't want to do any detection of when this would occur?

avatar image Drshk7 · Jul 16, 2013 at 06:50 AM 0
Share

I'm sorry I meant like kill on collider enter is not what I want. Sorry!

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Cornotiberious · Jul 16, 2013 at 01:57 AM

http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.OnCollisionEnter.html

you can do a little tweaking on the second code, and get exactly what you're looking for. instead of having the code instantiate a prefab, have the code ask

 if(rigidbody.mass>50){
     player.GetComponent(Health).hurt(damage);
 }


and that should only cause damage if the mass is over 50(you can change it to whatever number you want. (you could also make it do damage based on how massive the object is)

 if(rigidbody.mass>50){
     player.GetComponent(Health).hurt(rigidbody.mass);
 }

Does that help?

Comment
Add comment · Show 4 · 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 Drshk7 · Jul 16, 2013 at 06:52 AM 0
Share

All good but how about velocity? I mean just because a rigid body over the mass of 50 touching you wouldn't damage you right? Other than that, thanks. A lot of dislikes.

avatar image robertbu · Jul 16, 2013 at 07:11 AM 0
Share

You likely got the dislikes for "EXA$$anonymous$$PLE script strongly suggested." Too many posters look to people on the site to write their scripts for them rather than learning how to solve their own problems. So any references to asking for scripts gets thumbs down, and often the questions are closed.

As for 'velocity', change your check to:

 if(rigidbody.mass * rigidbody.velocity.magnitude > some_value){
avatar image barker_s · Jul 16, 2013 at 11:28 AM 1
Share

You might also want to tweak this check to better reflect the actual equation for kinetic energy and see if it fits your needs better.

http://en.wikipedia.org/wiki/$$anonymous$$inetic_energy#Newtonian_kinetic_energy

 if((rigidbody.mass * (rigidbody.velocity.magnitude * rigidbody.velocity.magnitude)) / 2.0f > some_value)
avatar image Drshk7 · Jul 30, 2013 at 01:31 AM 0
Share

When I said example script I meant something like this, not like a full script so I can get a head start. T.T Anyways, thanks bro.

Follow this Question

Answers Answers and Comments

19 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 avatar image

Related Questions

How do I reduce the bounciness of a ball affected by gravity in .js? 2 Answers

Rigidbody bowls/baskets - is there a better way? 0 Answers

Object Flies into Air Upon Collision, or goes through hill depending on isKinematic settings 1 Answer

Invalid AABB Error on collision :( 1 Answer

RigidBody immediately stops after AddForce 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