What happens when you go TOO FAR?

preview_player
Показать описание
👍 Learn to make awesome games step-by-step from start to finish.

🔴 RELATED VIDEOS 🔴

💬 Do you know what is going on in this video? Such a strange bug where a normal looking Sphere suddenly becomes all jittery and messed up.
The answer: Floating point precision.
Floats have a limited number of digits, so if you position an object in a huge position, it won't have enough space for many digits after the decimal point, they will be forced to round up or down. Meaning all the vertices on the sphere won't be able to go to their exact position, so they start jumping up and down as the value is being rounded.
One fix to this problem is a Floating Origin Point. This is where you can keep track of the player position, and if the player is too far from the origin you teleport them and the entire world back near the origin. As long as the relative offsets remain the same it won't have a visual difference but will help solve this issue.

📝 Some Links are Affiliate links which means it costs the same to you and I get a nice commission.
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

#gamedev

--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.

I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.

I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
--------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

💬 Do you know what is going on in this video? Such a strange bug where a normal looking Sphere suddenly becomes all jittery and messed up.
The answer: Floating point precision.
Floats have a limited number of digits, so if you position an object in a huge position, it won't have enough space for many digits after the decimal point, they will be forced to round up or down. Meaning all the vertices on the sphere won't be able to go to their exact position, so they start jumping up and down as the value is being rounded.
One fix to this problem is a Floating Origin Point. This is where you can keep track of the player position, and if the player is too far from the origin you teleport them and the entire world back near the origin. As long as the relative offsets remain the same it won't have a visual difference but will help solve this issue.
🔴 RELATED VIDEOS 🔴

CodeMonkeyUnity
Автор

"The engines don't move the ship at all. The ship stays where it is, and the engines move the universe around it"
-- Cubert Farnsworth, Futurama

ExpensivePizza
Автор

Minecraft had this problem solved because it used 32 bit Integer instead of float in chunk generation. Thats why it has a huge world with 30 million blocks distance from origin to each end

mojizabbas
Автор

So they guys developing Outer Wild, had to add some extra logic on the game to avoid this escenario. For the people that havent played, they implemented a scaled down solar system and when the player was reaching "exotic distances", everything was going to sh**. Their solution was always keep the user on the center of the Unity Scene and apply deltas to the environment.

xosemblanco
Автор

The problem with floating origin point and unity is that you can't use static objects, navmeshes and other unity solutions. I've read once that unreal doesn't use double, but it works with floating origin point out of the box, so the engine is already working with floating origin point and all their solutions are based on it.

raulzilla
Автор

In the SciFi game Im creating (vids under channel) i use floating origin.
Its necessary given the scale of the game im creating.
There are some caveats to deal with but there are very easy workarounds for them.
Using FO is basically mandatory for SciFi games.

NoTimeLeft_
Автор

Such an excellent video! Beautifully displayed and explained

Tarodev
Автор

I made a racecar game and one time my car fell off the edge of the world and I got up to use the bathroom. I ended up coming back to my PC hours later and the car became a twisted stretched out mess. I was confused until I read the warning.

DARK_AMBIGUOUS
Автор

I first learned about this from a behind the scenes with the Outer Wilds developers. They talked about keeping the player at the center of the coordinate system and moving planets to the player as you explore the solar system.

dustintaub
Автор

This is an issue I've had since starting out in game dev
even when creating art or models.

Its also a great reason for newer devs to start small :D

After_Pasta
Автор

Code Monkey's Consistency is all I want 🗿

Wonder_Verse_Tech
Автор

I did research on this because i ran into this issues with the physics of large objects falling extremely slow it also will mess with ui aswell.

Deaker
Автор

Yeah, outer wilds have an achievement where you have to go far away before the sun explodes, and you can see that the planets(and the map) start to go crazy.
I also encontered this when my friend was playing my game made for a gamejam, found a bug that led to infinity velocity, and got yeeted of the playable area 😅.

gabrielandraderosa
Автор

I find for most things floats are fine (just make sure you don't fall into the trap of errors in float comparison). When I something more accurate I switch to doubles. When I was doing scientific sims where accuracy is paramount we used doubles and decimals.

jeffreyhersh
Автор

Hope unity will add camera relative rendering to urp soon. And a correction to the video that: most of the modern games do not use floating origin, they use camera-relative rendering, which the origin point on gpu move with camera by default. Also, Unreal does not use double to store position, they also use camera-relative rendering. Using floating origin nowadays is not a good approach compared to camera-relative rendering because it needs to move large amount of object and will cause high memory usage and fps drop.

Misaki_eku
Автор

is this what happens with vertex jitter in PSX/PS1?

omochila
Автор

Your videos are always original and of high quality. Thank you for your ability to inspire and surprise!💶🌱‼️

JuliaGil-ot
Автор

So, if you do the invisible teleport... what happens with the light probes?

bvajagic
Автор

So if making a game like minecraft with procedural generation, and you need a coordinate system to show your position in the world, how would you handle it when shifting the world origin? Do you just keep track of how much the world have shifted and add it to the coordinates?
Similarly, if the world is generated using noise in world position, wouldn't it affect the world generation when changing the world origin?

ananthukrishna
Автор

How to shift world origin ? I show that video. An asset did it but if i don't use that asset then?

dharmeshkumar