Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Noxury · Jul 08, 2018 at 11:56 PM · collisiondamagecar physicsrelative movement

How to calculate improved car impact damage value?

Hi, Getting the value of impact is easy: using the relativeVelocity of the Collision field in

 void OnCollisionEnter(Collision col){ 
     impactSpeed = col.relativeVelocity.magnitude;
     //do further instructions with impactSpeed...
 }

Done. But, since I am writing here, you anticipate that this is not the best approach.

.

The problem with having only col.relativeVelocity.magnitude as your damage source is that you wreck your car when you are touching a wall at the side of it and maintain driving.

.

That is caused since it will return the cars velocity because the wall has no velocity (static).

.

Obviously the wanted damage should be low due to no/minimal velocity loss.

.

But substracting the cars' velocity to correct that doesnt help, it will give a value that is not lim->0.

 impactSpeed = (col.relativeVelocity - rb.velocity).magnitude; //should equal to rb.velocity - rb.velocity with non rigidboy collisions and (2*rb.velocity) - rb.velocity if 2 cars are colliding with same speed

So how to give a higher damage when the crash would stop the car more than a bump?

Is there an accurate formula for that?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Namey5 · Aug 21, 2019 at 03:28 PM

In my damage system, to get around that issue I took the absolute dot product of the relative velocity with the collision's hit normal and adjusted the impact based on that (that way objects colliding towards each other will do significantly more damage than those that are adjacent to each other), i.e.

 impactSpeed = col.relativeVelocity * Mathf.Abs (Vector3.Dot (col.relativeVelocity.normalized, col.normal));

I then just played around with some static modifiers until it looked decent.

Comment
Add comment · Show 2 · 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 Navii0 · Sep 22, 2020 at 04:01 PM 0
Share

'Collision2D' does not contain a definition for 'normal' and no accessible extension method 'normal' accepting a first argument of type 'Collision2D' could be found

avatar image Eno-Khaon Navii0 · Sep 22, 2020 at 06:27 PM 0
Share

Both the question and this answer were made with a 3D game in $$anonymous$$d. It's not unreasonable that Collision and Collision2D are different from each other. Despite that, you're not wrong, but it's also not really the point.

Regardless, while the answer also skipped a step, the goal was sound regardless. For any collision (2D or 3D), there are one or more points of contact. Assu$$anonymous$$g the first contact is desired (a common, albeit not universal case), you would use something more like collision.GetContact(0).normal to get the normal value of the surface.

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

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

Related Questions

Rocket projectile damage not applied on collision (message not sent/received) 1 Answer

Objects should simulate the real world like FPC 1 Answer

Damage by collision with ridgidbodies 1 Answer

On collision deal damage each few seconds and doesn't keep consistent collision? 1 Answer

How to Detect Collision, Calculate Velocity+Mass, Apply Damage 0 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