Unity Shenanigans - Part 2

Trying new Surfaces

I've decided to make new surfaces to render them on Unity. For this, I also developed a way to define and store these locations in the code, which can then load the prefabs that contain these surface models.

All these locations are first defined in a class called Catalogue as variables, and then initialized. Each of these locations, stored as a SurfaceLocation class, holds 4 important data points:
  • Latitude and Longitude: With this, one can specify where in the planet's surface the location is, as to render the sky (Sun, moons, ...) in the correct placement.
  • Prefab: The string name of the prefab at specific folder inside the Resources directory. Using this folder instead of adding all prefabs in a script with a lot of Serializable Fields makes it more user-friendly to add new locations.
  • Celestial Body: To get information on what to render in the sky, color of the atmosphere, ..., the Celestial Body (Planet or moon) where the location is must be specified.
A little snip of creating a new location:

Catalogue.loc1 = new SurfaceLocation("loc1_prefab")
    .SetCelestialBody(Catalogue.my_planet, -1.8f, 52.5f)
    .SetSpawnPoint(new Vector3(2.35f, 1.429f, -30.44f), -90, 16.5f);

A constructor creates a basic Location by passing the name of the Unity Prefab that will be loaded when loading such location. To specify the planet and the latitude/longitude, a separate function must be called.

Decoupling the data that specifies the location in the planet from the location itself allows one to make locations that aren't at the surface of a Celestial Body, like for example, a space station!

Then a final function is called to set up the spawn point of the movable character, alongside where the camera should be pointing at.

Mars-Like Surface

For new surfaces, I decided to make two, one that looks like Mars, and another that looks like the Moon.

The Mars like one was definetly the hardest one. I had access to height data from Earth, which I used for the cliffs at both borders of the valley, but I also wanted to use Mars height data, which ended up being harder.

After a lot of searching around the web, I finally found the webpage where all the height data that MOLA (An instrument aboard the Mars Global Surveyor Spacecraft), but the file format was extremly weird. It ended up being a pure raw data file, so I could rename it to .raw from .img and load it up.

With this new data on my hands, I added a nice dried river valley to the place!


Moon-Like Surface

For the Moon-Like planet, it was very easy, as I had already done planets like this for previous projects, so it was a matter of copying the heightmap, adding some new coloring, and done!

Moon-like surface

A movable character?

This was actually the first thing I tried to do for this little project, a character that can move around.

I also needed a texture, but I'm not very good at drawing characters, so behold, Stickman Mc.Stickface!


Stickman Mc.Stickface walking around

Because I know nothing about Unity's Animation System, I decided to make my own animation system for 2D planes by using a shader, which takes different elements from a texture sheet.

Modeling a structure

As you can see in the previous gif, there's a whole structure where this character can walk around! I'm no 3D artist, so this tooka lot of time to make, and even though it's not finished, I really like how it looks!

There was a lot of pain to try to make how big the pixels in the textures looked consistent, a lot of Pythagoras was involved with the inclined surfaces.

For the style of the structure, I tried to go with a near-future scientific base in the middle of the ocean, kinda looking like today's oil rigs.

Another view of tjhe structure

A Low Poly In-Situ Resource Utilization (ISRU)

Future

University is picking up speed, so I probably won't be able to do much in Unity.

On the other hand, one of the assignments we are going to do is recreating a game from scratch, including making our own small engine. We will be using C++ and SDL2, and so far I'm enjoying it a lot, so probably expect me to post about the things we end up doing on it!

Comments

Popular posts from this blog

A world of sulphur and heat - Redesign of Kevari

A Lava planet - Redesign of Troni