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):
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?
- 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.
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