I've got a control point-based car physics model.
Vector3 pointVec = state.nextSubPoint.transform.InverseTransformVector (transform.position - state.nextSubPoint.transform.position);
Vector3 pointVec2 = state.nextSubPoint.transform.InverseTransformVector (state.subPoint.transform.position - state.nextSubPoint.transform.position);
state.t = 1 - (-pointVec.z / -pointVec2.z);
So far so good, but while making a feature, I realised that the track had "gaps" on the outside line, where state.t would flip between above and below 0, as two sub-points would pass each other the position of the car indefinitely each frame. The inside line position is also predictably inaccurate. This is undesirable.
You can see the issue in this picture, where the magenta line on the left marks the gap.
![alt text][1]
I've tried various things involving the X and Z components of pointVec and pointVec2, but to no avail. I'm convinced there's a simple way to do it that I just haven't found. Would anyone happen to know what that is?
Thanks in advance for your time.
[1]: /storage/temp/207440-screenshot-20230522-100231.png
↧