Regenerating Vehicle/Wheel data on the fly?
Posted: Fri Jan 10, 2014 4:24 pm
Hey again,
Making some good progress with the library but I've run into an issue (bug?) when modifying some variables of the Vehicle class at runtime.
We need a system that can generate a random vehicle (wheelbase/wheel size/suspension) when the player taps a button. I previously implemented a few simple functions that access the Vehicle's List of <Wheels> and then subsequent shape/suspension data to modify the values on the fly. This worked perfectly fine up until the vehicle is placed on a flat terrain collision mesh or a flat box collider..
- When the terrain collider is uneaven (even to just heights of 0.002f variance) the vehicle will regenerate and behave normally with the new settings.
- When the terrain collider is created with flat values, the suspension glitches out and just bounces continually.
I have just implemented a work around that destroys the vehicle and re-creates it, but it's messy and you get that awkward 1 frame gap of having a vehicle, no vehicle and then a new one - instead of neatly switching.
I thought it may be something to do with my implementation of the space or scale, but i quickly tried it in the Terrain.cs demo in the source downloads and it did a similar thing. (As an aside, we have a requirement in the project that the terrain is to be completely flat)
Any ideas on this?
Cheers
Making some good progress with the library but I've run into an issue (bug?) when modifying some variables of the Vehicle class at runtime.
We need a system that can generate a random vehicle (wheelbase/wheel size/suspension) when the player taps a button. I previously implemented a few simple functions that access the Vehicle's List of <Wheels> and then subsequent shape/suspension data to modify the values on the fly. This worked perfectly fine up until the vehicle is placed on a flat terrain collision mesh or a flat box collider..
- When the terrain collider is uneaven (even to just heights of 0.002f variance) the vehicle will regenerate and behave normally with the new settings.
- When the terrain collider is created with flat values, the suspension glitches out and just bounces continually.
I have just implemented a work around that destroys the vehicle and re-creates it, but it's messy and you get that awkward 1 frame gap of having a vehicle, no vehicle and then a new one - instead of neatly switching.
I thought it may be something to do with my implementation of the space or scale, but i quickly tried it in the Terrain.cs demo in the source downloads and it did a similar thing. (As an aside, we have a requirement in the project that the terrain is to be completely flat)
Any ideas on this?
Cheers