Code Design: Networking in Unity

Working with Unity has been a learning experience for the entire team, for every time I’ve been cursing it for something weird (like the LineRenderer) we’ve also been praising Unity for being awesome (the Particle System comes to mind). Personally this is the first time I’ve been working with a single game engine for this long and my prior knowledge is more towards the back-end side of things as I’ve mostly been working with XNA and SDL which aren’t game engines by their own right but libraries to create them.

Being more of a back-end programmer I wound up (voluntarily) with the goal to create the network part of Orbital Gear. Unity does have some great features with their NetworkView class, you can easily sync all the information inside a Transform, which takes care of the position, rotation and scale so it’s the same on all connected clients. The Transform syncing also has some settings on how to handle network lag and you can quite easily set up a game that has basic online play. So far so good, the NetworkView do have some design decisions, though, for Orbital Gear this has been how to set the member variables in all the clients while trying to take into account the possibility of massive lag and cheaters.

The obvious way to think is to use the NetworkView.OnSerializeNetworkView() that’s already in the NetworkView class, but it has some problems that we need to solve, namely that “It is automatically determined if the variables being serialized should be sent or received, see example below for a better description.” This fact present the problem that if the client decides what its member variables should be assigned to the possibility of cheating us only a step away for a programmer that knows his/her stuff as you can just change the value in the RAM via an external program or via DLL-injection and the other clients would just abide to that mindlessly. This has lead to our current solution which is to put most of the game logic on the server and update the clients accordingly, this resembles how popular games like League of Legends and Dota 2 does things, all your input is sent to the server, the server calculates and sends back the result.

1:  [RPC]  
2:  public void setHealth(float a_health) {  
3:    if (Network.isServer) {  
4:      networkView.RPC("setHealth", RPCMode.Others, a_health);  
5:    }  
6:    m_health = a_health;  
7:  }  

The game logic for setting health in Orbital Gear

 This code is designed to prevent setting health on a client and have it update on the other clients and the server, you can actually set the health on the client but no logic that reacts on your health is placed on the client so that would just bug out the health bar until the next time you get a health update from the server. The server will also have logic to prevent the remote procedure call from being called by the clients, in short, a lot of anti-cheat will be done server side in an attempt to ensure that games are being played in a fair way.

Unfortunately there is little hope to go entirely cheat-free in games, as long as they are run on a local machine there will be ways to cheat and modify it, part of the learning process will be to know how to handle cheaters.  Hopefully our approach will reduce the cheaters and the bandwidth need as this is not an evil scheme to impose some online-only DRM, joining a LAN server works just as fine as playing online and some single player game modes is in the plans, but that will wait until later 😉

– Joakim “Joxe” Clysén
Twitter: @Joxedin

Orbital Gear Development #1

Hello people! Binarin here.

This is the first development post from Night Node. They will be written by the programmers and they cover more technical things, like what we’re working with now and what problems we have.

While Joxe is making cool stuff in the backend, that I don’t dare touch, I can look at adding new things to the game. That is, as long as Crylar won’t bug me about adding his particles.

So I’m currently looking into how we can make our “planets” more unique. I’m using the functionality I added a while ago, that let’s planets override things like how the player moves and the normals of the surface. The aim is to have planets that can have any shape! Or at least planets that are not completely round, coz’ that would be boring. To try this out I’ve made a planet out of a cube.

Skärmavbild 2013-11-21 kl. 14.11.38

After a bit of fiddling I got it to work. However, it looks silly as the player moves around a corner because there is no transition of any kind. I will probably make the player airborne as he walks over corners.

I’ve also tried making a planet that takes it’s shape out of it’s mesh. This turned out to be tricky, even if I managed to make a algorithm for making a 2D shape out of the mesh, I would have to save it somewhere. I could probably put the code in a custom unity editor to make sure it was only generated in edit mode, and store it in the planets serialization. But instead I think I’ll just take a array of Vector2s from the editor, that way we can customize the shape more freely without worrying about the mesh, and I don’t have to that 2D shape convertion… Like, where would I start? find the face to the left and follow it clockwise and save every edge? … No.

Joxe will probably write his own post from home some time this week. But he has done some nice work with Unity’s network library. We can almost play multiplayer without crashes again ~woohoo.

If you have any questions or just wanna talk, you can contact me on anton@nightnode.se. Have fun and keep hyping!

@CyberBinarin

Gamex 2013

Greeting and salutations fellow humans!

So on Friday we took a trip to Gamex to check out the scene ^_^ So what did we do at Gamex? Stand in line of course! After all it is a video game convention. The indie games they had at the Square booth where great. It’s fun to see the creativity of our fellow indie game studios. Vic Bassey was the man that setup the Square booth. We must say that we are impressed and thankful with what he has doing for the Swedish indie game scene. Here are some pictures 😀

20131101_131440 20131101_121134 20131101_114455 20131101_113612 20131101_113543 20131101_113104

 

 

One less lead designer.

So today our lead designer aka GFX guy got sick 🙁 It’s funny how the mood of the office changes when one person is away. Time has gone by much slower today without Crylar. So we can’t wait to have him back in the office working on the game and making it beautiful.

Get better soon Crylar!

207509_10150156167471433_6721503_n

 

Maybe this video will help out! it’s both cute and educational.

Project Gravity Update.

Oh hello again.

Last week right about when we were leaving the office we got the multiplayer up and running 🙂 It’s far from done but it’s fun to see that you can play against each other. There is a lot of work to be done before we can release any kind of playable content to the public, but that day will come.

Here is a video of Binarin and Crylar trying out the multiplayer.

Today we have tried out the game with a controller and it feels great! Both Mowhammer and Crylar are huge console gamers so that was a little childhood dream of theirs to play the game they made make with a ps3 controller.

20131021_113407_4

 

No case of the Mondays here 😀

Trying out the new updates!

So we have been working hard to get the Mech to work in the game and we have finally got it to work ^_^ No more cube! It’s so rad how everything changed when you have a character that moves in the game instead of a cube.

We also encountered a bug with the camera during the testing of the game!

20131018_134021

Here is a video of the Mech in action!!

 

Saturday fun with Night Node

Hello!

After a week of hard work and fun you need to relax so we decided to get together at Crylar’s place. He has a lot of video games, so if you want to have friends over you should get yourself some. MowHammer made plenty of pizza for everyone!

So what games did we play?

  • Future cop LAPD
  • Tekken 3
  • Soul Calibur V
  • Guilty Gear X2
  • Armored Core 1 and 4
  • Castle Crashers
  • Spelunky

Here is a picture of how much fun we had =) Crylar’s girlfriend and sister also joined the Night Node fun.

20131012_201916

 

A friend of ours found our videos very silent so he fixed that! Thanks Johan Kalén!

Project Gravity Update.

Oh hi!

We just finished our budget for the game and if we get the investment we need we can have the game ready in mars of 2014! On the development side we are working on the gravity elements of the game.There is a lot of math involved in that process. But it’s going great, thanks to both Crylar and Binarin who are really good at math ^_^

A minor update is that one of the harddrives on the GFX computer died 🙁 Our CTO Joxe gave his condolences.

But don’t worry we are still smiling.

team_night_node

 

 

The journey

Oh hi!

Wow it has been an amazing journey so far. We started out in Anton’s apartment working on a kitchen table trying to find some way to make this indie game studio to work.

ghetto office

Now thanks to Omnicore we have a real office to work from!

New Office

 

It was so cool to have the first prototype for the game done and having our Lead Designer Rasmus evaluate the prototype to see if this is the game that we are going to set into production.

And later on to see the game’s progress.

 

 

Another app in the works.

We found a problem now we must solve it. Lending stuff to your friends is a nice but getting it back is often a pain in the back. Memory isn’t always everyone’s strong suite so we are making an app where you can share without despair.

app_project