Enemy spotted!

Moving the character and throwing some snowballs works so far. But since Super Snow Fight is about snowball fights, we need someone we can fight with. Throwing snowballs in your own face is not that much fun in the long run, I guess.



That’s why you can see two cubes with cylinders now in the YouTube clip. The green one is the player character, the red one is the greatly feared enemy. It won’t be a real fight if your enemy ist just standing there doing nothing. So we need a little artificial intelligence. The AI to this date is quite simple. My goal was to keep the enemy moving and throwing snowballs at you, but not in a predictable pattern. This means we need some random juice.

With this method the enemy character will move in any random direction. What’s left is the time the character should change its direction. Counting the time in the Update()-method and calling ChangeMoveDirection() if a certain time is reached will do the deal.

Now what about throwing snowballs? In Super Snow Fight you are able to charge your shot or throw. Holding the left mouse button will increase the power behind your snowball, which then will make more damage. Well, your opponents do not really hold the mouse button. Instead I gave them a random power and a random time they wait until they throw their snowballs. In some situations it’s not really fair, e.g. if an opponent spawns right next to you and shoots you down with full power. But in my opinion the game is still easy enough to be fun and getting bashed all of a sudden may create some laughter.

Last but not least, enemies focus on the closest player. You can try this out when you play the game and walk up to a guy fighting against another AI character. If your distance is the smallest, he will turn around and tries to beat you up!

And that’s the code. GetClosestPlayer() determines – you guessed it – the closest character. LookAtPlayer() then uses this character to rotate the model. Calling LookAtPlayer() in FixedUpdate() will keep your opponent up-to-date.

In the beginning there were blocks, cylinders and spheres

When you come up with an idea for a game, you almost certainly want to play it right now. But, of course, you have to make it first. What a shame. Well, no, it’s not a shame, it is great! Because that’s the part that is so much fun of making games, right? Right! Nontheless, you want to play your game fast. But without any models, sounds, sprites or any asset at all you might build your prototype with so called primitives. These things are simple three dimensional objects like cubes and spheres. They can have textures attached, but don’t have to. Instead of using primitives, you could hire a designer to make models and stuff for you, of course, but without any gameplay, you won’t know if your idea is even fun. So, if you don’t want to spend your well earned money for a boring game, try the primitives.

Super Snow Fight is all about snowball fights. This is the main idea about this game. So I wanted to build an application with Unity3D where you can move an object which can throw an object. That’s it. The first thing I realized was that I have to know where the front of my object is. So my snowball-throwing-object consists of a scaled cube with a cylinder as nose (the front) and a simple sphere for the snowball. And, of course, I need a plane for the terrain.

The code I wrote made it possible to move my object – which is the player character – and throw a snowball. Hope you get the idea in this little YouTube clip.