Inception, or How I Lost My Mind.

posted in Septopus for project Unsettled World
Published October 02, 2018
Advertisement

Well, this is the first post for a project I've been working on for a few months already. 

So, let me rewind a bit....

A few months back I started toying with the idea of making a game with an actual spheroid planet as the core of the environment.  Yay Unity and Blender!!  A few weeks of toying around and I had a pretty neat little 5000m diameter spheroid planet with custom gravity and a player character(UMA v2) running around on it. 

Well, that was way easier than I expected...

It was at this very point, the actual madness began to set in.  Well, it's working, I guess I should make a game out of it...  Okay.  Hmm, online?  Of course!  Hmm, mmoYES!  Oh, damn, I've really lost it now.  Crafting, well, certainly.  Mining and hunting?!  Don't be silly, yes yes yes yes, all the yes.

Bigger? hmmm.... hmm... yes?

Let's try 10000m radius..  hmmm...  Jittery character movements.. and jittery everything... hmm... 

9000m radius?  all good... hmmm...

And this is where I learned all about the floating point precision problems of 3d engines at great distances from 0,0,0..  Fun stuff.  Only slightly maddening.  But, in the end, also easily solved by rotating the entire freakin planet periodically so the player character and camera stay close to 0,0,0.

Let's pump this guy up to 30000meter radius and call that good for now. 

I ran across a few other jitter problems along this winding path but those were solved through the careful use of the "FixedUpdate" vs "Update" method selection.  Moving anything that involved my custom gravity or physics in general to a FixedUpdate method was the solution for most cases.

So, we got a character and a planet...  I guess we need stuff to do. 

And from here the rabbit hole only started lengthening, until there really was no beginning or end.

So, there's one of the nutshells...  The inception!

Over the next few days I'm going to try to detail as much of the current guts of this beast as I can for anybody who's crazy enough to follow along, while trying to not distract myself from creating more of them of course. 

 

Project Stats:

Unity Game Client Lines of Code: 24,032

Avatar Server Lines of Code: 2,480

Economy Server Lines of Code: 387

2 likes 0 comments

Comments

Stragen

FYI - There are issues with Unity and very large numbers for positioning that leads to jitter problems, the floating point precision in unity suffers at large numbers as you've already discovered, when you talk about 30km radius objects you're going to hit these.

I read about this issue in passing so i'd have to find links again, but i do believe there are some assets on the assetstore that will help with this... the work around is something in the realm of 'rehoming' the camera to origin and moving the game world around it when you have the camera position exceed a set limit from origin. IIRC it was somewhere around the 10,000 mark but thats going by memory.

October 03, 2018 02:30 AM
Septopus

"But, in the end, also easily solved by rotating the entire freakin planet periodically so the player character and camera stay close to 0,0,0."

I should have expanded on that a bit as it took a few days of research and imagination to resolve.  The fix was not only the periodic rotation back to 0,0,0, but the 30km offset for the planet is kind of important to mention as well.  Smaller terrain segments and a lot of code shifted around between Update and FixedUpdate, there were a lot of things that went into the jitter issues..  I'm sure there will be more.

re-homing, re-zeroing, I ran across the actual technical term in another thread on here "origin re-something" or something.. haha, and promptly lost it..  I ended up implementing all the fixes in my own code though.  Unfortunately, I find that most Unity assets are either too heavily tied into the built in gravity or otherwise not a good fit for my environment, AKA just way too much money.

October 03, 2018 02:47 AM
Stragen

How did you implement the gravity? Just using inbuilt rigidbody kinematics or your own code? I ask because i was considering a similar system, using Unity, but have slowed down on this part due to not being confident with the floating point dramas - not a hurdle i want to try to jump just yet...

I'm curious as to if 'moving the world around the camera' lead to unexpected behaviour with those systems and calculations....

October 03, 2018 03:22 AM
Septopus

My "gravity" basically amounts to turning off the default gravity, setting the value to 0,0,0.  Followed by writing a script that applies the same acceleration force(to a standard rigidbody) but with a vector that always points towards the planets center.  That script is attached to everything that needs gravity applied to it(this may change, if only for simplicity sake).  Pretty much everything else physics wise is standard/default.  Like you I was very weary if I would be able to make any of this work before diving in, I figured the physics and 3d maths would just get all kinds of screwy and I wouldn't be able to untangle it, not the case I guess.. ;) I'll go ahead and dive into the gears of how I got my world spinning on my blog tomorrow morning.  It's probably the biggest hurdle I've run into so far(code wise) and deserves some space and documentation.  Plus I should review all that again, been a few weeks since I touched any of it. 

October 03, 2018 03:56 AM
Awoken

Can we see some screen shots of your freaky madness?

[ never mind, I just read your next blog entry :D ]

October 04, 2018 01:37 AM
Septopus
7 minutes ago, Awoken said:

[ never mind, I just read your next blog entry :D ]

I made a few edits and left a comment about the same time you left this reply, dunno if you saw them.  Thanks for giving it a read!

October 04, 2018 01:45 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement