+2 votes
by
edited

I am using Vehicle Physics with a Floating Origin script, which moves the car and the world back to the origin when it gets over 1000m away from the origin (to prevent issues such as glitching shadows/prefabs when far away from the origin). The vehicle controller in Unity's standard assets had no issues running with this script, however, Vehicle Physics causes the car to (basically) explode.

When I first start the game (with the car at about (-10000,150,-5000) and immediately moving to (0,0,0) along with the world) the car flips front first and lands upside-down, which makes the game unplayable unless I start the game with the car in the air. When I'm driving and get 1000m away from the origin (when the floating origin script is activated) the car goes flying into the air while spinning (although it doesn't flip when this happens). When I was using the vehicle controller in Unity's Standard Assets, the car would continue driving normally when the floating origin script was activated.

Is there a way to fix this without disabling the floating origin or vehicle physics script?

Here's my floating origin script: https://pastebin.com/HFEfE74B

by
I haven't yet tested VPP with floating origin. Can you please share the floating origin script you're using so I could reproduce the problem?
by
I used a free/simple script I found on Github, I can't find the repo link but here's a pastebin link to it: https://pastebin.com/HFEfE74B
by
edited by
I confirm you there's a problem here and VPP vehicles don't play well with floating point origin. I'll let you know when there's a fix available.
by
I had that problem. I don't remember the solution but, have you looked to see if there is any collision with the UI at the moment of going to 0, 0, 0?
by
I'm testing in scenes without UI, and the problems persist.

I've found that one cause of the issues is the VPHeadMotion component. This component creates a very light ridigbody and attaches it to the vehicle with a joint. Translating the vehicle doesn't seem to translate the child rigidbody, so the joint enforcing the constraint causes the vehicle to spin. This is not the only cause of issues, so I'm investigating this further.

1 Answer

0 votes
by
edited by
 
Best answer

Update: support for floating origin is now available in all editions of VPP. The only requirement is calling:

VPVehicleController.NotifyPositionChanged (Vector3 offset) 

in every VPP vehicle right after translating the entire scene with the vehicles to the new position.

by
Thanks for the answer! I also have to say, this is some of the best support I've gotten from an asset since it's been fixed almost a year later.
Also if I understand this right, do Professional/Enterprise support floating origin and the Community edition has to run the function every time to support it? Or do only the Pro/Enterprise editions have the function?
by
Thank you! Yes, this has been a long-standing issue but it had to be solved eventually.

Floating origin support will be available in all editions as a core feature. I've edited the answer for clarification. In all cases, it requires calling the method right after repositioning the vehicle.
...