Loading...

The blog is being migrated and merged with multiple Imphenzia blogs so the format and content will be inconsistent for a while.

Astrofighter.Net - Now suddenly loving C#

Today I redesigned the code for weapon handling in Astrofighter.Net and the game now supports very dynamic creation of weapons and weapon upgrades. Each weapon is configurable with tons of settings such as various sound effects, autofire, charge up for increased power, rounds per minute, and so forth. In all there are about 40 customizable settings for a weapon and for potential powerups / upgrades.

While rewriting, and documenting, my code it strikes me how much I'm starting to like C# and the intellisense autocompletion of all variable names and functions. Today I learned about the ability to use the {get;  set;}  feature to treat a variable as a property - quite nifty. What this means is that you simply define a variable like this:
public float velocity { get; set; }

This enables you to from other scripts access the variables directly:
// this automatically uses set
remoteScript.velocity = 10;
// this automatically uses get
Debug.Log(remoteScript.velocity);

The only downside is that you can't have these variables show up in the Unity inspector to assign them a default value which is a shame. There is a workaround for this in Unity but it requires a bit of code bloating so I simply don't use inspector configured values in this case.

I'm very happy with today's progress as it enables me an incredible level of control of my weapons and powerups. Should be able to create tons of cool upgrades that split bullets, enable homing missiles, alters velocity and force of projectiles, and so on.

Astrofighter.Net



Astrofighter.Net is my new game development project for learning Unity and C#. During the past week on every spare moment I've been able to find I have been developing and creating assets for the game. When I'm not on the computer I am coming up with about a billion ideas for the game, or at least so it feels like.

If you want to read about Astrofighter.Net directly - skip this next section =)

The dangers of being in a situation such as mine is starting a tremendous amount of projects and never finishing them. With "a situation such as mine" I mainly refer to the wide spread of hobbies I have, all of which must fit in to an otherwise normal life. Non-computer based hobbies aside (motocross, photography, martial arts, spending time with wife, two children, and friends) I am, as many of you are aware, currently dedicating much of my time to:

  • Being the independent electronic artist Imphenzia with 85 tracks and 6 album releases to date - this includes maintaining my custom created artist site, maintaining presence at Spotify, Youtube, Facebook, Twitter, Soundcloud.com, Soundclick.com, and Ubetoo.com. The custom web site is created in PHP and I think it's the 6th generation (each being a complete rewrite.)

  • Being the composer Imphenzia Soundtrack with over 250 songs/loops and 260 sound effects available for licensing - this also includes maintaining the custom created site.

  • Being the game developer and graphic artist Imphenzia Games with completed 3 game releases (Beat Ball, Beat Ball 2, and Netris.) Again - maintenance of the custom created web site for the official site and Beat Ball 2.


I'm proud of my achievement over the years, especially fitting all of it in next to my every day that normally takes up 8h + 2h commuting every weekday. I have one project, however, that has been my bad conscious for a long time. It's been nearly 10 years since I started "Computer Touring Car Championship" (CTCC) which was later renamed to "Performa Cars." This game is still unreleased but as I recently announced in a blog post I will release the game but without network multiplayer (only split screen), and it will be freeware since it's using such dated technology.

I have to accept defeat when it comes to implementing multiplayer in Performa Cars simply because I didn't consider the nature of network gaming when I started making the game. It would take a complete rewrite of the game (more or less) to make networking work and it would not be time well spent since it's using unaccelerated 2D graphics that probably utilizes less than a single percent of today's graphics cards. Seriously.

There is new hope, however. I've used BlitzPlus, Blitz3D and BlitzMax to develop Beat Ball 2 and Performa Cars and I've really enjoyed the Blitz-range of products over the course of 10 years. Lately I discovered Unity3D and I first dismissed it a year ago. Who want's to make a game in an "editor" I thought?

How to waste time


No, I thought. I want full control of my game development. I need to see every line of code and be sure I structure the games exactly how I want. This is how you waste a lot of time by the way =)

In Unity I trust


When I gave Unity a second chance, I looked at a whole bunch of video tutorials on YouTube. The tutorials explained Unity in a step by step manner, going through the editor, all the windows, hierarchy, types of game objects and so forth. Unfortunately I can't remember which series of tutorials I watched - but Google the topic and I'm sure you'll find many great tutorials. Giving the step-by-step demonstration of Unity a chance helped me tremendously and I fairly quickly started to make some simple scenes with a bouncing ball, colliding objects, particle systems, etc.

My ultimate goal is to re-create "Performa Cars" as what I refer to as a "2D-but-3D" game with the multiplayer functionality it so much deserves. Using Unity instead, I'll be able to cut down development time and also make great use of the power of modern computers and graphics cards.

My "2D-but-3D" approach, as seen in Beat Ball 2 and in the coming Astrofighter.Net game, is making the game look like an old-school 2D game but using the visual and physics power of 3D engines. I think many developers are too tempted to tilt the camera down into the 3D scene since "it's possible." And I agree 3D games are awesome, but I am fighting the temptation to tilt the camera as I want to make 2D games and I know there are a lot of fans of 2D games out there so this one is for you =)

Rather than jumping straight into making the new top down racer in Unity I wanted to make sure I know how to develop a multiplayer game. This is why I am first attempting to make a simple multiplayer space shooter game.

Astrofighter.Net


As I mentioned early on in this post, I've dedicated a lot of my time the past two weeks when I started a real stab at creating a game in Unity. I am amazed at how fast I am able to make progress in Unity being such a novice at it. In just a matter of two weeks, Unity has enabled me to create the basic foundation of space combat game that already supports server side authoritative network multiplayer with client side prediction.



I captured the footage above today as I tested the current build of the game with two of my mates. It runs very well already although latency is very low at 30ms so I'll do more thorough testing using a 3G modem with 150+ ms latency. The YouTube version of the video is choppy since YouTube reduces the frame rate from 60 FPS to 30 FPS. You can download the 60 FPS H.264 version of the video to see exactly how smooth the game flows.

So far I've implemented the basic networking code, the spawning of player ships with the choice of two weapons. A Blaster and an 80mm Gatling Gun Cannon =) The blaster is single fire and the Gating Gun fires 800 rounds per minute. There will be loads of ship types and weapons with upgrades - I have an excel sheet with loads of goodies and ideas.

The game uses true physics with rigid bodies and real life forces. I'm really happy with how easy Unity is allowing me to just assign my ship, for example, a weight and what force it should apply during movement and the physics is just "taken care of." It also looks very promising how I can use the physics aspects even during multiplayer.

To prevent cheating, and to ensure collisions don't behave differently, the server takes care of all the physics and collisions in an authoritative way. The clients also animate the objects but if a cheating player hacks the game to move twice as fast on his own computer the server will warp the player back to where he belongs. Feminists can attack me now since I referred to the cheater as "he" but surely women don't cheat, right? =)

Is it a felony to have this much fun?


I'm having so much fun with this project that I even feel stressed when taking a break. This lengthy blog post is also hogging time from Astrofighter.Net but I want to make sure to post about my progress.

Today I also registered Astrofighter.Net - and I know I know - there was a game from 1980 named "Astro Fighter" but I don't have a space and I added ".Net" to emphasize it's a networking multiplayer game.

Networking with Unity3D

For years and years I've been wanting to create a network multiplayer game. Ok, I already created one about 10 years ago called Netris but that is a type of game that does not rely on any sort of speed or major synchronization of game data.

I tried to implement network multiplayer capability to Performa Cars (previously named "Computer Touring Car Championship") - but I had to throw in the towel in the end. Too many design issues with the game itself (how the physics was implemented) and lack of proper networking libraries for Blitz3D proved to be too big of an obstacle.

New hope


Today I bought an asset package called "Ultimate Networking Project" for Unity 3D. It's a combination of a tutorial and a bundle of useful scripts and functions to simplify multiplayer networking in Unity. I've read through the 25 page tutorial and looked at the included examples and I'm very hopeful to be able to create a multiplayer game in Unity.

What appears to be promising in Unity is built in functions for interpolation/extrapolation of object positioning along with client-side prediction and server authority. If these terms are alien to you, let me assure you that they were to me as well when I started to make Performa Cars. It's a world of hurt if you have to learn and develop all these functions by yourself - but as I mentioned, Unity appears to have this under control.

My first project is to create a simple top-down space shooter (using the low polygon 3D spaceship I recently designed.) The purpose of this project is to learn enough about Unity and networking to have another go at the top-down racing game I've always dreamed of creating.