Showing posts with label Unity. Show all posts
Showing posts with label Unity. Show all posts

Monday, June 14, 2010

Death Zone Zero: Minor Update: Client Server Network

The Battle Server is slowly starting to take shape. Players can log-in, get their unit data from the database, and load units on the battlefield. Can't control them yet though. But with the work I've done in the single player demo, the template is there. I just need to add the multiplayer network part to it.

Photobucket

One thing I don't like about Unity is the lack of better serialized data transmissions across the network. I made a formal request about it here: http://feedback.unity3d.com/forums/15792-unity/suggestions/824649-better-network-serialize-commands
Oftentimes I need to send a bulk of data to the client to initialize his data. I have 2 options for doing this: RPC (Remote Procedural Call) or a OnSerializeNetworkView function.
The problem with using an RPC is you pass the data using arguments. My data includes arrays of classes so using an RPC is problematic.
I can use instead a OnSerializeNetworkView function and serialize the data into a stream. The problem with the current OnSerializeNetworkView function is you can't control when exactly it gets called. OnSerializeNetworkView is meant to be called continuously, and has to be attached to a certain Network View.
I need a Serialize function that would get called only when I tell it to, much like an RPC.
Having worked with the Torque Game Engine, Torque has what they call a NetEvent, basically a one-shot serialized data transmission from/to Server and Client.
This is perfect for initializing the Client with data, or when the Client needs to submit a list of information to the Server (like when buying/selling multiple items from/to a shop).
And please, if this gets implemented, please make it available to the Unity free version.
My guess is allowing a BitStream to be a valid argument to pass in an RPC is the most straightforward way to do this.
Right now I'm faking serialization by turning my data into one long string and sending that to the client. This, I guess, takes up a lot of bandwidth since strings in Mono are 16-bit each character because of Unicode support.

That's ok, I tell myself. Just imagine the client is loading a web page. Heck, maybe even the average web page is larger than what I'm transmitting. And I'm not sending it every loop or something; its for initializing client data, so a one-time, large bulk of data transmission is quite allowable.

It makes me miss my days when coding in Torque Game Engine. You can squeeze all the bits of data you want as small as possible there. They have their own version of the BitStream: Like a normal stream you serialize your data, but the special thing is the compactness of the serialization. Transmitting a boolean requires only one bit, strings can be compressed to save space, and you can specify by how much bits an integer or float is going to take when serialized into the stream.

For example, say you have an integer variable health, which in your game goes only in the range 0 to 100. You can then specify the health variable to be serialized to only 7 bits (essentially creating a 7 bit integer, which goes in the range 0-127), since its value goes only up to 100. You saved 25 bits, assuming it was a 32-bit integer, a whopping 78% of the original size.

They even have what they call a StringTableEntry. Basically used for strings that get sent over the network frequently, like usernames or preset error messages. What happens is the first time its sent, it gets sent as a normal string, but the next time, it gets sent only by a reference ID number to save bandwidth.

Friday, June 11, 2010

Death Zone Zero: Minor Update: Client Server Network

I got a rudimentary Client/Server network up and running with a chat system. Code based from the network tutorial given by M2H (http://www.M2H.nl).

Photobucket

Saturday, June 5, 2010

Death Zone Zero: Minor Update: Syntax Errors Galore

I'm currently transitioning my code from Unityscript (Javascript) to C#. C# has its own quirks but nothing unmanageable. I figured I need C# because C++ plugins only work in C# via Dllimport. It'll be a very long time before I can use C++ plugins though (needs Unity Pro), but its better to do the conversion to C# sooner than later.

C# certainly has a stricter syntax compared to Unityscript and allowed me to catch some bugs that otherwise slipped by me in Unityscript.

C# also has preprocessor directives (something Unityscript doesn't have), which I need to use. Unityscript also has preprocessor directives.

I find C#'s typecasting more readable than Unityscript's.

Photobucket

Thursday, May 20, 2010

Death Zone Zero: Minor Update: Doc's Support Ability "Steroids"

The Doc now has his support ability, Steroids, which, I've said before, raises the attack damage of a friendly organic unit, but damages that unit as a side-effect. The effect lasts for 2 turns and you can stack it.

Photobucket

As usual, the work-in-progress, playable demo is available at http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html

Weird thing is he can raise damage of a unit even though the guy uses a gun to attack. Then again, the Marine of Starcraft also uses a similar idea with their Stimpack ability, and they use guns too.

Tuesday, May 18, 2010

Death Zone Zero: Update: New Unit "Doc"

The Doc is your post-apocalyptic healing unit. He can heal a large amount of health to one organic ally unit. The problem is he has no combat training so he can't attack.

Still to come: The Doc's support ability, Steroids, which enhances an organic ally unit's attack damage but damages that unit itself as a side-effect.

Photobucket

Thursday, May 13, 2010

Death Zone Zero: Update: New Unit "Gunslinger"

The Gunslinger is like your standard ranged-attack unit, except that he really shines in indoor maps where there are lots of walls, because his shots ricochet off them. This also means you can attack units hiding behind cover, while being behind cover, provided you can find an angle that allows you to do so.

Again, I'm still using the placeholder 3d model, so they all look alike right now.

Photobucket

As usual, the work-in-progress, playable demo is available at http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html

I made some dummy walls in order to demonstrate the Gunslinger's ricochet ability.

Monday, May 10, 2010

Death Zone Zero: Minor Update: Bullet Ricochet Test

In this post I show a work-in-progress of the Gunslinger unit's special ability to make his shots ricochet off walls. Its kinda like in billiards games where you see the potential trajectory your ball will make before you make a shot.



I got my inspiration for this from Metal Gear Solid 1 where you fight Revolver Ocelot and his bullet shots would ricochet off the walls.

Wednesday, May 5, 2010

Death Zone Zero: Update: New Unit "Cannoneer"

New in this update is the Cannoneer, a mobile artillery unit with a devastating, far-reaching attack. The only problem is the projectile takes a long time to get there; when the Cannoneer attacks, his shot only arrives at the target at the next turn, giving enemies a chance to run and take cover from his attack.

Photobucket
http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html

Note that I don't have a 3d model for the Cannoneer yet— heck, I still don't have concept art for him yet, so I'm still using the placeholder 3d model of the Rifleman.

Friday, April 30, 2010

Death Zone Zero: Update: Preliminary AI now working

The enemies will now retreat when their HP becomes 50% or lower. That's about it.

Photobucket
http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html

Language Discrimination

Photobucket

I had a funny thing happen to me just now. I couldn't get any help in Unity's IRC chat channel because I use Unityscript, Unity's version of Javascript, instead of the more sophisticated C# language.
[11:41] <_underdog> hi all
[11:41] <_underdog> I got a question
[11:42] <_underdog> when I put a yield WaitForSeconds in my function, Unity gives me the error "The return type of a generator must be either 'System.Collections.IEnumerable' or 'object'."
[11:42] <_underdog> any idea why?
[11:43] <blitzwing> language?
[11:43] <tigeba> http://unity3d.com/support/documentation/ScriptReference/index.Writing_Scripts_in_Csharp.html
[11:43] <_underdog> unityscript
[11:43] <blitzwing> learn C#.
[11:43] <_underdog> why whats wrong?
[11:44] <blitzwing> its js... you're stunting you're abilities
[11:44] <_underdog> what's wrong with js?
[11:44] <_underdog> what does it have to do with the problem at hand?
[11:45] <blitzwing> the only people answering you are C# coders :)
[11:45] <_underdog> discrimination :(
[11:45] <dr_link> Shame how C# is Microsoft made. :(
[11:45] <blitzwing> not really
[11:45] <_underdog> yes it is
[11:45] <blitzwing> MS put a lot of time into it
[11:45] <dr_link> Not necessarily this version of C#
[11:46] <blitzwing> Anders Hilgberg was Mr Delphi.
[11:46] <dr_link> lol @ his name
[11:46] <dr_link> anyway
[11:46] <_underdog> I hate Microsoft btw
[11:47] <blitzwing> good for you.
I was given some help later on.
[11:49] <tigeba> _underdog: FWIW when people ask about that error its usually because they are using C# but trying to use the unityscript syntax
[11:50] <tigeba> for the coroutine
[11:50] <_underdog> hmmm I see, its weird tho, I'm using unityscript all the way
[11:51] <tigeba> try the coroutine example
[11:51] <blitzwing> well its not wierd, thats just a common mistake people new to C# make
[11:51] <tigeba> in the docs, it should work
[11:51] <blitzwing> seeing you're not using C#, it doesn't appy to you

Friday, April 23, 2010

Grenade Skill Update

Photobucket
http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html

The grenade deals damage (in a spherical area) and it has its own icon now. Some bug fixes here and there. Still missing are some explosion particle effects, sound effects, and a "throw grenade" animation.

Thursday, April 22, 2010

Grenade skill work-in-progress

I just found out that I have a wisdom tooth growing. I've never heard of wisdom teeth until now. It hurts; the pain is tolerable but irritating. Apparently it needs to be taken out using surgery. Why do teeth have to be so difficult to manage...

Anyway, in this update, here's a work-in-progress of the Throw Grenade skill, which is supposed to be used by the Army Private unit, of which I don't have a 3d model yet. So, I just added it as another skill for the Rifleman for now.

Photobucket
http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html

Its still a work in progress, there's no icon for it yet, using the skill doesn't do anything besides launching the grenade (which is only a sphere for now); it doesn't do damage yet.

Well, its 3 AM, I'm hungry and I need to sleep. I better go.

Wednesday, April 21, 2010

Strategy RPG Test Update

In the end, I ended up using plain old object-oriented programming, subclassing skills to more specific skills. I thought using the component-based approach would give little benefit, seeing as in my design, each skill is quite unique from one another. Having a mix-and-match component implementation would be of little benefit since I would then have made components that, in practice, would only be used once or maybe twice.


Photobucket
http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html


New in this update is the Rifleman's unique skill, the Bullet Barrage, a ranged attack that, while powerful, leaves the Rifleman unable to attack for 1 turn afterward because he needs to reload his expended ammo.

Under the hood, a lot of refactoring was done, a few bug fixes, and now the game loads unit information from XML files. The Rifleman's XML file is found here. It should be noted that the values used are simply test values.

Monday, April 5, 2010

More Unity 3d Projects

I've been more busy with Unity 3d lately. Working on features that I'll be including in the Strategy Game Test that I made.

FogOfWarTest
Here I made an implementation of fog-of-war for strategy games. It uses a mesh blanketing the terrain, whose vertex colors I set depending on if units are in range or not. Enemies appear and disappear depending on whether they're on fog or not.
Photobucket
http://anomalousunderdog.herobo.com/Unity/FogOfWarTest.html


ProjectileTest
Here I made code for launching projectiles like grenades.
Photobucket
http://anomalousunderdog.herobo.com/Unity/ProjectileTest.html


Unit Insignia
I'm planning on letting players upload whatever picture they want and use them as unit insignias; logos visible on the unit 3d models themselves when battling.
Photobucket


XmlTest
I made a simple XML parser which I will use to load unit properties from XML files. I did this so unit properties can be edited without requiring Unity being run.
Photobucket
http://www.unifycommunity.com/wiki/index.php?title=TinyXmlReader

Tuesday, December 1, 2009

Back Again

Thought I'd get back to blogging after all this time. Long story short, I've been using Unity 3d now.



Photobucket
http://anomalousunderdog.herobo.com/Unity/Gobs.html

A side-scrolling action game. There was supposed to be more features but I never got to finish it. The white thing in the back is supposed to be a caravan that the player is guarding while it travels. Shown here is a test level with a few enemies.





Photobucket
http://anomalousunderdog.herobo.com/Unity/ZombieFields.html

A zombie game, but similar to Crimsonlands. There were supposed to be several modes of play but only "Survival Mode" and a prototype "Assault Mode" was implemented. There was supposed to be leaderboards too, but it would've required a MySQL database server hosting which I don't have.





Photobucket
http://anomalousunderdog.herobo.com/Unity/DZZPrototype.html

A work-in-progress of a strategy game I made. Its actually a prototype I hope we could show to investors to get some funding to make it a full-fledged game. Though its doubtful because of the economic recession.