Posted July 17, 2018 by imphenzia
#unity3d #blender #imphenzia #That's Racing
I'm implementing some safety features around the track like fences and tire barriers. Safety should come first, but as it sits right now it seems to be far away from the truth! I am getting some serious volatile collisions with even the slightest of movement of the car. Check it out for yourself:
It's like the Hollywood feature has been left enabled! It doesn't happen all the time but luckily enough it's not too difficult to reproduce, it just requires some patience:
I am somewhat confident that it isn't a Unity bug. The car is modeled with individual parts and each part has a collider and a FixedJoint. The FixedJoint is configured with a breaking force so when a collision is detected that exceeds a threshold for the strength of the carpart the FixedJoint breaks and a rigidbody is added to the car part so it can behave as expected as it falls off the car. As the car part is detached it is also moved to a different physics layer so it now can collide with the car itself and car parts that are still attached to the car. I think this is where the problem of the volatile behavior lays.
I added a debug log to the car parts and I noticed that twice it was tail lights that experienced a break force in the millions rather than in the thousands. When I had a closer look the tail lights collider was overlapping the rear bumper and I assume that when the tail lights broke off and it was overlapping the bumper it resulted in a massive collision to break free.
I have temporarily fixed that now and I have to see if the volatility is gone. I will be revisiting the way the car parts are attached soon anyway so I will be able to make sure it stays stable.
As you can see I've also started to add some objects like tires and fences.
I am experimenting with performance as I've implemented each fence segment with it's own box collider and a fixed joint with a break force. This way I can have the fence staying intact for slight collisions, keeping the car from going off course, but break apart for head on collisions. I am not sure if I will be able to keep it that way performance wise but I think and hope that the fence rigidbody, collider and fixedjoint is sleeping most of the time unless within bounds or being interacted with so I'll revisit this topic later. The result is quite nice so I hope I can keep it this way:
Finally, I've also added a new Water Mill to the track. I ended up making another low poly Blender video, this time a time-lapse, to show how the mill was made - maybe you can find some use of seeing how it was modeled and implemented into the game: