NokiMo
codysmods
codysmods

patreon


WorldBox 3D

Yo! This ones a little long but is like a shitty dev blog. Hope you enjoy and have fun with the mod!


Around a week ago I remembered seeing a video where another person made the camera rotate around the world. It gave a really impressive angle of the world but had a pretty big bug: the world would be cut off the further you rotate.


https://imgur.com/hOWRfkc


Credit to Danielb1405 for the gif and inspiration for this project. 


I thought maybe if I could fix that world clipping bug and add some simple lines, I'd be able to see building positions in a new and interesting way. I did that,  and then took it a few steps further afterward..


https://gfycat.com/frenchoffbeatguernseycow


I started by googling.


https://i.imgur.com/hZhVhjj.png


First, I had to figure out how to rotate and move the camera. That was simple enough, although my controls still need some improvement..


Then I could get to work on the actual bug. Which wasn't really a bug, just a camera setting I had to change. Something called a "clip plane" needed adjusting. Basically there's a specific area that the camera is able to render objects in, otherwise they clip and disappear.


From there I had the ability to rotate around a world that no longer disappeared. But the world is flat and nothing is on it. All the buildings and people are way up in the air at different heights.


https://i.imgur.com/Q7hetCg.png


From what I understand, the height dimension is used to sort each object into layers and prevent the wrong layers from hiding behind each other. Normally, our camera is locked at a top-down view, so whatever layer is highest is closest to us and won't be hidden by anything beneath it/further away. 


Buildings in the sky were an easy thing to fix so I prioritized them first. I tried a few methods and settled on a very small chance (0.02%) for every building to have its position grounded every game tick. This winds up happening around once a second and doesn't affect performance noticably even on large worlds, which is great. It's a pretty sloppy solution but no one will notice.. Probably. I'll try and change it later to only ground them when they're created and upgraded.


Next up were creatures. I tried the same method of grounding them as I did with buildings, but they instantly disappeared again, turning into just a shadow. Turns out their Z coordinate (3D height) was being made to equal the Y coordinate (2D height) by the game usually. With a simple change they are always made to stay on the ground as well. 


Now that the objects that matter the most are flat on the ground properly, I need to rotate them. This is done to give them the actual height dimension instead of staying flat on the ground. I add to the positioning code one more line that simply assigns their rotation as well. 


Strangely enough, I have to rotate everything to go below the world rather than towards the sky. If I don't, there's strange visual bugs. But smoke and glow effects already go towards the sky, so now it looks like they're going away from each other. Smoke and glow, UFO, lightning, clouds, and all sorts of other objects need their own positioning and rotation for 3D to be fully complete.  For now though, I'm happy with the result. 


I'm not sure what else to say here unless I want to dive into the seperate 3D mode for rendering the world, but that one is much buggier and I've probably already bored most of you, so another time.


Check out the WorldBox 3D mod, available now in my discord server as well as the official WorldBox server!


My server: https://discord.gg/fQFAZPV

WorldBox server: https://discord.com/invite/worldbox



 




Comments

Kinda thought the pictures would embed. Clearly I don't know much about creating a nice looking post here, sorry!

Cody Pettus


Related Creators