Saturday, February 22, 2014

ScriptableObjects - you shiny cute thing!

Given my ultra-lack of experience with Unity (and C#) I spent a couple days researching and working on ScriptableObjects. There are useful pages on the Unity site along with some excellent blog posts and found a great YouTube video.

Working example:
I got my "factions" example up and working and can easily create new factions and alter the existing ones via the editor. (As seen in this video).

...and then it hit me!

SCRIPTABLEOBJECTS ARE FOR READONLY DATA!


Sadly it wasn't until I actually got my example to update an existing faction that it hit me. All scriptableobjects are stored in the READONLY bundle. FFS!, what an idgett!

EDIT: They are of course still very useful in reducing memory as described HERE.

Monday, February 17, 2014

Universe Creator - close to pre-alpha status

The Universe creator is coming along nicely. Just resolved the faction sub-division problem by using what I called a "FactionMatrix" prefab. This guy has "sub cubes" layer out in random patterns that use OnTriggerEnter to report a newly created "sphere" (system) so that I can set the systems ("sphere's") faction properly.

This gets into the fundamentals of the design; as to how many factions and their layout based on the universe "seed" number. Given that every galaxy will have two additional factions:

  1. None
  2. Unknown
If the GC (Galaxy Creator) aka player chooses to use three factions, the galaxy will actually contain five total.



Creating and debugging the faction alignment process was fun and had me stumped for a bit but the solution is rather light-weight and fast. Especially since it only has to be run on the creation of each new universe.

Oh and StartCoroutine() and yield are my new best friends... :-)

Saturday, February 15, 2014

Hey, don't be a SQUARE man...

Working on developing the method to sub-divide the galaxy into the appropriate factions. I started our thinking okay... the galaxy is like a sphere so hey lets sub-divide the sphere...



WTF was I thinking... sphere's are just a PIA to figure out location, volume, size, etc...

...and then... it HIT me!

What about a CUBE??? FY! Let's use a cube and fill it with sub-cubes and whatever systems are in each sub-cube belong to the appropriate faction!

Sweetness..... behold a WIP


So now all that's left is to add a box collider; run an OnTriggerStay and collect the objects (aka systems) that are inside (each box) and they all belong to that faction!

OMG, it's looking like a real flippin' galaxy! super-sweetness!

BTW - I freakin' love this shi, er stuff.... :-)

EDIT: Galaxies are NOT usually inside spheres but laid out in a flat disc like structure and so...


there we have a shiny new "flat" Galaxy dics.

Thursday, February 13, 2014

For the love of While loops!

Wow... I suck at C#, there's just no sugar coating it!

I spent several hours this afternoon modifing the system generation function to add in a DISTANCE check (e.g. so that two system are not too close to each other).

Sounds simple right? Sure....

Um yeah... I've never had to FORCE QUIT Unity more times than this afternoon than in ALL the times I've been using Unity.

So... here's what I learned:
To use a WHILE loop inside of a FOR loop - create a separate function and have that function run the WHILE loop and RETURN the result (solution).

Here's some screenshots of code:

        if (i > 0) {
            Vector3 validPos = ValidateNewPosition(ExistingPos,i,newPos);
            newPos = validPos;
        }

And here's the function:

    Vector3 ValidateNewPosition (Vector3[] ePosint currentIndex , Vector3 target) {
        // Yeah - this frackinworks!!!!
        while(true) {
            bool FoundOne = false;
            for (int sysNum = 0sysNum < currentIndexsysNum++) {
                if (Vector3.Distance(ePos[sysNum],target) < distanceBetweenSystem) {
                    Debug.LogError("[" + sysNum +"] Failed Check " + Vector3.Distance(ePos[sysNum],target));
                    FoundOne = true;
                    sysNum = currentIndex + 1;
                }
            } 
            if (FoundOne) {
                target = ScalePosition(urand.PointInASphere());
                ExistingPos[currentIndex] = target;
            } else {
                break;
            }
        }
        return target;
    }





Finally! Progress...

Back on track and (finally) making measurable progress. Here's a screenshot of the Galaxy Creator tool. Using a seed based random generation we will be able to replicate the start of any universe created in Skyport Alpha.



Here's the high-level overview of the Skyport Alpha Universe[1]:

  • Single Universe in each game
  • "X" Number of Galaxies (now set from 1-3)
  • Between 16 and 256 Systems per Galaxy
  • Travel between galaxies will require a GALAXY PORTAL
  • Travel between Systems (in same Galaxy) will use a JUMPGATE


Notes:
[1] Game design is in fluid state and can (and probably will) be changed or altered.

Tuesday, February 11, 2014

Unity and PlayMaker

Layout...

Just needed to link a quick image to the PlayMaker forums while they repair the attachments function.

More images below:

Um, yeah seems this is how to NOT design an FSM ;)

This one seems to be working sweet!

Another screenshot








Wednesday, February 5, 2014

Still working...

Just a quick update that we are indeed still working on this project.

We've rolled back to the design stage and are reworking the games objectives and re-scoping the project.

It will indeed still be a Unity 3D project.