woensdag 22 mei 2013

Rhino and his friends!


Hi!

Today im going to tell you something about making a Player script that can actually be used on anything and how to maintain a better view.  But first im happy to tell that we are working on some new projects! Together with Matthew Im working on a spin-off of a game Xform made 2 years ago.
Of course everyone knows this little fellow!

Rhino with the T-Rex
As you can see we are making this game in Unity. I've been busy with learning my way around in Unity cause mainly code in AS3. Luckily the difference between AS3 and C# isn't that big, if I compare it to lingo:)

So when I started almost a month ago I started programming with the player script. Not knowing what the project will be about or what the rhino will be doing. So I started my playerscript, like any other, basic input, assigning a model&materials, some physics,etc... Just some basic functionality.
But then there was a meeting and we decided that the rhino won't be the only that can be controlled. So now I know we will be needing a dynamic script for switching the models/materials/animations. Not that hard, we can set that in its "Init" function to let it know which prefab it's going to need.  These prefabs are perfect for us programmers, we can drag and drop it to the scene, sets its material, physic collider(box, sphere, mesh), animation(done by artist), save it as prefab and its ready for use!
But what if all these controllable objects will be having different states or lives, resets, switches..
Now comes the fun part, at least I like it. We will be needing a BasicPlayerScript that will handle some basic functionality.

  • No hardcoded links to prefabs!
  • Basic Init, get and set its paramters, and let the specific init handle the rest.
  • Float function, so we wont have collision all the time to save some performance
  • Variable movement, every object has its own speed, jump force
  • Able to receive input and handle input. Create the most common behavior and if a object is going to do something else we can override the function and let it do something else.
  • State machine! :) Handle the current state. Walk when it needs to walk, wait, jump, die, etc.. Here again, make them very common so when an object needs to do something else let it override the normal one.
  • Generic stuff.. like changing materials, reset, pickups, and if we need something specific we can easily run its original and add extra functionality if needed

This way we can easily create objects and let them use this script so we can control it. Why are we doing this, well, if we want the rhino to run and jump, same goes for a car, flamingo, rex or whatever we wont need to type or copy paste the same code over and over. And when an object needs to do something specific, instead of jumping flying, we can easily adjust in its own script instead of messing with the basic functionality. 
So when we want a rhino, flamingo or whatever we will create a script that will extend the BasicPlayerScript.

This is something you really want when you are dealing with multiple objects that have the same functionality. When there is a small adjustment it will be done for all and if you need a specific adjustment it will done its own script.

And check out our latest release 
http://www.agame.com/game/super-mud-mania.html

Greets,
Michael


2 opmerkingen:

  1. Okay then...

    This might sound really creepy, maybe even kind of "supernatural"

    HOW would you like it if you could simply press "PLAY" and LISTEN to a short, "miracle tone"...

    And suddenly attract MORE MONEY into your life?

    And I'm really talking about hundreds... even thousands of dollars!!!

    Sound too EASY? Think it couldn't possibly be REAL?

    Well then, Let me tell you the news...

    Many times the greatest blessings in life are also the EASIEST!!!

    In fact, I will PROVE it to you by letting you listen to a REAL "miracle money tone" I've synthesized...

    YOU simply click "PLAY" and the money will start coming into your life.. it starts right away..

    TAP here NOW to play this magical "Miracle Money Tone" - as my gift to you!!!

    BeantwoordenVerwijderen