- Home /
The floating point origin and AI
Hello everyone.
I felt I should ask this question before i get too bogged down in it and find that the path leads to a dead end.
I'm working on a space simulator and have managed to procedurally create the milkyway, this is pretty useless though atm as I can physically use it for the mpment.
But for creating solar systems, a scale issue came up and i thought a clever workaround would be using multiple cameras and a ratio speed script to recreate the solar system at a 1AU scale and then have the objwcts scale up in the main view as the subscene camera moved near to a planet.
However, this subcamera is slaved to the main camera and the main camera moves at a 1:1 scale which means when moving forward it can cover large distances.
However this still wasn't a viable solution because of the floating point problems at distance. Searching the net i found a solution called "floating point origin".
Now i understand that basically this moves everything to you and the camera used stays at 0,0,0. However i have a feeling that this solution would cause problems with AI characters, yet there are no mentions on the net if this is a problem or not.
So my question is, does the floating point origin affect how AI behave?
Thanks
I am currently thinking about same problem, and my idea is to create some custom wrapper around transform, that uses double precision (opt. any other number format). All logic is calculated in doubles using these transforms, and only then the float values are generated and fed to the engine itself. The only place where i think i won't be able to make this work is builtin subsystems like physics, lightmap baking etc...
I'm ok with the physics side of things as i won't be using phisics or lightmap baking etc, and i'm trying to avoid doubles for performance purposes.
The AI just uses traditional transform.translate and transform.rotate, it's just if they get moved back whether it's going to screw them up if they're doing an intercept, evade, patrol etc
well i know nothing about your ai, but if they are 100000 km away from the origin and try to move at 1m/s at 50fps, they might as well not move at all OR move by epsilon every frame OR move in different direction (caused by rounding each axis movement up or down)
That's why i'm looking at the floating origin solution, but obviously if it can be shown or proved that it doesn't work, then i guess i'm going to have to scale back the production and leave it for a future update
This question could have different solutions that derive into long discussions, and it might stay unanswered for an undeter$$anonymous$$ed amount of time. Please help us improve Unity Answers with concrete questions and answers, and consider using Unity Forums which is a great place to discuss ideas. Thanks for your comprehension, Unity Support.
Answer by unimechanic · Feb 22, 2014 at 02:32 AM
The answer to this question depends on how you design the scales of your world, and the system that you choose for your AI. This video could help you to solve the first requirement:
it is a awesome solution with floating point/origin but how do you create it? i dont find the information :/
Your answer
Follow this Question
Related Questions
Mapping from External to Unity World Coordinates 1 Answer
simple 2d car Ai 0 Answers
Transform.translate change 1 Answer
Center position after scale 1 Answer
Scripting for AI 1 Answer