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 Noxury · Apr 03, 2015 at 06:21 PM · uicardamagesensor

Collision Car Sensors

Hello, I am trying to introduce a damage-System for my car game like the ones in Destruction Derby. I have thought about 6 sensors which are located at their specific positions of the car: frontLeft, frontRight, middleLeft, middleRight, rearLeft, rearRight(see image below at CarStatus):


look at CarDamageStatus

Because I am new to Unity I don't know much how to do this. Shall I split the copied and invisible carmesh into 6 parts and let them be the sensors which the script is continiously looking whether they are colliding and if true send the Hit-Count converted in color (green=noHit;red=maxHit) to the UI-triangles?

  1. So far I have written the color-assign part:

    GameObject.Find("Damage_FD").GetComponent(RawImage).color = Color.Lerp(Color32(255,0,0,125), Color32(84,255,0,125), hp_FD);

Damage_FD.getComponent(RawImage).color is the Front-Drivers UI-Image-color.

Color32(255,0,0,125) is full Red (alpha ~ 0.5).

Color32(84,255,0,125) is Green (alpha ~ 0.5) with HSV value 100, so it fits for the start value of hp_FD.

hp_FD is the Lifepoints in int starting usually from 100 (no damage on this sensor) to 0 (max damage).

This above works for all 5 other sensors. But the color changes not smoothly according to the hp_SENSOR values. It changes, when they are 0 from green to red and not gradiently.

2. The mesh-replacement-function is in thought way easier: When the Hit-Count of the sensors reaches something other than 0, then the trunk as an example for rearRight or rearLeft-sensors is replaced with a damaged trunk and so on for the other sensors.

But the sensor indication needs to be working first to go on further with the replacement.

Any help is appreciated :)

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
0

Answer by AlwaysSunny · Apr 03, 2015 at 06:21 PM

Some old-school damage modeling!

You should "split" your meshes into logically sensible chunks you can swap in and out as needed. The actual collision detection can and should be handled by simplified convex shapes. You might get by with six box-colliders arranged to correspond to the six desired areas. Mesh colliders are fine too, but you should adhere to the best practices associated with creating good mesh colliders; these are common-sense modeling practices, info can be found here and there if needed.

If you wanted to get a little fancier, you could use some simple physics math to scale the damage received based on the momentum of the impact. That way it'd take 50 fender-benders to equal the damage of a single head-on high-speed collision, etc...

Comment
Add comment · Show 1 · 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 Noxury · Apr 03, 2015 at 07:10 PM 0
Share

So as you said there should be 6 meshes and they get each replaced when they are colliding? Now that's really oldschool! ;)

yeah I have already did the UI-Image Sensor-Status to change the Status of the specific sensors depending on the current speed of the car (higher speed = higher substraction of the Life):

  if(Collision != null && hp_FP >= 0){//FP-Sensor = hit:
          hp_FP = hp_FP - mySpeed/dmg_multiplicator;


now I have to fix the if condition because I have assigned a s$$anonymous$$dy Box-Collider for the whole car based on James' Arndts Video which is always colliding the ground so the colision gets true and that's not real because the car loses health by hitting the ground.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Car Collision Damage 1 Answer

Unity 2D Car Side Scroller question. 1 Answer

Control car throttle Input based on distance‏ 0 Answers

Damage Indicator not showing correct position of attack. 0 Answers

C# CarDamage script: Array index is out of range error. 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