Sunday, 17 November 2013

My First Unity3D Project

Killer Core

Those of you that have followed my old XNA blogs will know that I have had the idea for Killer Core rolling around for an age, have had it in pretty much every release of XNA and of each of the engines I have created with XNA. With the announcement that Unity3D will be a valid development platform for the new XBox One I thought I might as well start work on porting what I have to Unity3D.
I am using the freeware version of Unity3D rather than the Pro, firstly, I am a hobbyist and so have a budget of zero for my projects, but once we can develop for the new XB1 those of us that have registered with the ID@XBox program will get Unity3D Pro for XB1 for free :D So, when that becomes available, I will upgrade my projects to that. Also, in the mean time I can deploy my games in the internet and you guys can tell me just how much it sucks :P
So, I thought I would show you where I am with the project after about a week of development with Unity3D. I don’t get a lot of personal development time, it’s done in my lunch and when I have a free evening or two. This always leaves me thinking “What could I do if I was able to dedicate 7 hours a day to this stuff…” If I win the lotto I’ll find out I guess.

Where was I last week with it?

Last week I had got to the stage where I could create simple scripts and get models on the screen, so I started off by getting the models I had already created in the XNA version(s) and get them into Unity3D. I also have some simple physics and started to play with the basic particle systems, and it looked like this:-
As you can see, my modelling skills are as bad as ever, but, I am trying to focus more on the game mechanic. You will also notice the glitch that occurs when I shoot my first shot, and that the particle systems are destroyed along with the parent object. Both of those things are now resolved and Ill show you what I did to remedy them after I show you what it currently looks at.

Where am I with it now?

As I say, I have resolved the initial creation issue for the shells, I did this in my Shellshooter C# script. I added a void Awake() function, and in there I simply create an instance of the shell, and destroy it there and then.
void Awake()
    Rigidbody t =  (Rigidbody)Instantiate(Block, new Vector3(10000, 10000, 10000), Quaternion.identity);
As you can see I place it a great distance from the scene too just in case my destroy call is not called in a timely manor, not that I can see why it wouldn’t but cant hurt can it :)
So, how about the particle issue, well I had a global static method in my Globals script that I wrote to handle the destruction of objects, so when the object is killed I call Globals.ObjectDeath(gameObject, HideOnDeath); The hide on death parameter is used so if set, the object is hidden first so it’s particle emitter can carry on and the object is then destroyed after the HideOnDeath value in seconds :)
public static void ObjectDeath(GameObject gameObject, float hideTime = 0)

    if (hideTime != 0)
        gameObject.renderer.enabled = false;

        if (gameObject.rigidbody != null)
            gameObject.rigidbody.isKinematic = true;

        if (gameObject.collider != null)
            gameObject.collider.enabled = false;           
    Destroy(gameObject, hideTime);
As you can see, if the hideTime is not 0, i disable the objects renderer, then it’s physics components so they don’t hinder the scene either, the intrinsic Destroy call then handles the destruction of the object after a given time.
So, not the greatest clip in the world, but it’s progress, and I think I have managed to do quite a bit in the short time I have been working in it. Unity3D really has surprised me by how much I have enjoyed using it so far.

What next?

Lots of stuff lol, get a blast effect in there, I would like to get my old XNA flames working in there, so will have to read up on how to create my own shaders next. I am going to try and make a blog post each month if I can. Really need to sort out my terrain/platfom mesh’s they really suck. I can use Blender, I just don’t have the patients for creating decent UV maps, maybe I should :S
Hoping that by the time we can develop the game will almost ready to go into test/release, fingers crossed eh…
Ohh did I mention that the XBox One launch date is the same date as my birthday, how cool is that lol, it will be a new born, but alas, I will be a creaky old 42 :(

No comments:

Post a Comment