Unity3d: Using A* and grids for entering a football field

Just played with the A* algorithm and a grid to make players enter a field and assume the initial 4-4-2 classical formation. Notice there are dumb and smart teams A bocca aperta [Read more…]

Social Share Toolbar

Unity3d: Giving runtime prefab instances meaningful names

This is a short note about a minor issue you may meet in Unity3d when you are creating scene objects in code, say from prefabs.

In my case I am creating a soccer field borders on the base of a grid that may resize, so I want to create everything in code.

Unity3d object instance with meaningless nameI am as always giving meaningful names to variables (and you should too) and so it would be nice to get the instance to be named as the variable, without duplications and without – oh horror – writing the instance name as string, breaking code esthetic and refactorings. In the pic on the side you see what you get by default – not cool.

Actually in the rich and hackable C# universe as managed in current Unity3d this is possible: just this way:

image

Thanks to this post here. I used it this way:

image

imagegetting good names on the instances Sorriso

 

Note that this relies on unspecified behaviour and while it does work in Microsoft’s current C# and VB compilers, and in Mono’s C# compiler, there’s no guarantee that this won’t stop working in future versions. See the discussions here:

Getting names of local variables (and parameters) at run-time through lambda expressions

Finding the Variable Name passed to a Function in C#

Update: It seems like this might no longer be an issue from C# 6, which will introduce the nameof operator to address such scenarios.

If you have suggestions on how to automate getting good instance names at runtime (maybe with cleaner / lesser code) let me know!

Follow me on Twitter where I post about game design, game development, Unity3d 2D, HTML5, serious games.

Social Share Toolbar

Game Development with Unity 2D – part 6: Pixel Perfect

Here we have a nice chat with the sinful Daniele Giardini about pixel perfect in 2D games, as a form of holy perfection.

We are continuing our voyage in Unity 2D development; previous trips: Part 0, Part 1, Part 2, Part 3, Part 4, Part 5.

We didn’t find a satisfactory definition of pixel perfect online, so this is Daniele’s: [Read more…]

Social Share Toolbar

A note of the wild use of “if(object)” in Unity’s C# code

Looking at other people’s C# code for Unity, I kept seeing this bizarre usage of if:

if (object) { …}

where object was a real object, not a bool instance. This is a JavaScript kind of usage, where there is a big (perceived) mess about object and value types, so I wondered how did C# “automagically” cast to bool? You cannot do that in classical typed OOP languages like Java.

Turns out there is nothing about this in C# itself, its MonoBehaviour that implements implicit boolean casting

public static implicit operator bool($classname$ me){
return me != null;
}

Actually you will have to navigate the hierarchy up to Unity’s Object to find it. See also here.

But if you are learning C# with Unity, be careful as “This can be really confusing because that behavior doesn’t carry over when you start using standard .net libraries and other 3rd party code that is agnostic to Unity.” – here.

And neither it will when writing your classes, when not extending MonoBehaviour, so its not a healthy habit to catch.

Follow me on Twitter where I post about game design, game development, Unity3d 2D, HTML5, serious games.

Social Share Toolbar

A note on slimy static Unity3d gameObject instances

A quick note on the state of C# static variable instances in Unity3d.

So I just discovered that static properties of classes extending MonoBehaviour on level reload may get reloaded or not, depending on circumstances.

The problem is this: you may need in your game development to have a singleton manager class instance which is also a game object. [Read more…]

Social Share Toolbar

Learning to design a learning game (how Tonzilla was born)

Let me talk a bit how I started developing the idea and the following design of Tonzilla, my first serious game that will be published this fall.

Goals

I had two goals in mind:

my first goal was that I wanted people to express themselves more and better.

Simple topic isn’t it? It can be translated in many ways, and I declined these lines:

  • people need to not be shy
  • people need to know their expression instruments
  • they have to train on them

as color, I couldn’t develop anything that wasn’t fun to play, serious or difficult topics are easier to deal with if you have a minimal fun with them.

So… what’s our primal expression instrument? Our voice.

freedom-of-speech

A game where we have to use our voice, and train it to liberate our expression engine, having some fun with it…

I started feeling something nice in this idea.

Since the consciousness and main behavior of a human being gets formed in the first 7 years since birth, it’s much better to start being free to express ourselves as young as possible.
So this game should be playable by kids.
An old guy can play a child game, but a kid usually doesn’t play an adult one.

(Later I then decided to dedicate mostly to K12.)

My second goal was that I wanted people to feel better the relationship between themselves and the outer world

So… what is our interface with the world? mostly our body.
We usually care about its health or its aspect, but what about its spatiality?

What if the player had a giant body? Should she care more about how she moves and touches things? What would be his POV (Point of View)?

Descartes_mind_and_body

My Skills

So I had some ideas I wanted to put into my game.
But how to translate them into gameplay?
What should the player do in this game to start dealing with his voice and having a giant POV?

I asked myself: what skill & technology do i know/like?
I’m good with audio signals, I know musical theory, I have basic in 3D space and I think that Virtual Reality is such an interesting topic… uhm.
I also know what could be fun to do in a virtual world where you can use your voice freely.. I even have a 5yo son I play the piano and sing with…

Marketing Research

Let me search a moment around: how many published voice controlled games are there around? How many of them have Virtual Reality integration and have levels that help the player improve their vocality?

Very very few, maybe one (in the future!). It was a GO GO.

The Idea

Here was my idea: the player was a grown up giant in a big world, and the sounds emitted by his voice could interact with the objects around. Different kind of sounds, different effects.
Would be fun to destroy buildings with a scream, to blow away clouds, to levitate rocks with a hum, to generate beats with rhythmic sounds…

voicegp

Wow.. nice!
Dressing this idea with things that could be easily picked by kids and everybody revealed that you could be a giant monster arriving in town and, like Godzilla teaches, you can destroy everything! This is was a very simple description of the game, and the marketing dept. approved.

Technology

Let me see if I really can achieve this game plan with the technology I know: I can develop with Unity, I know the basics of audio signals (FFT and spectrum analysis), I can create simple 3D worlds, I have Oculus.. yes it can be done.

But I want kids to play with it soon.. so I wanted to make both an Oculus Vr version, and a mobile tablet/smartphone one.

There weren’t technical obstacles (you know maybe sometimes you have an idea which is very difficult to be developed with current technologies)

VR-graphs

Final Steps

I’m not a good designer at all, so i needed a design partner. Luckily I found Emiliano Granatelli (TodaviaNo) who was an old friend, huge designer, and like me was just wanting to enter the gamedev world.
Working with him we got the title “Tonzilla” (it sounds very similar to Tonsil), with a VR^2 standing for Vocal Rampage and Virtual Reality
also the story of being a child reading a Godzilla comic sitting on the WC, and getting asleep you would them dream the gameplay.

tonzilla_screenshot12-menu-1

the graphic style was defined by trying to find a simple / low poly world with very nice looking.. old comics were in B&W, so why not to use that?

tonzilla_alpha_00 tonzilla_screenshot11-1024x655 tonzilla_screenshot10-1024x652

You’ll see the rest of the development, and the nice features we’re keeping secret until you’ll discover them in the game (no spoilers here 😉

Features and Levels

As prototyping started giving something real to play, keeping short iterative redesign many many new ideas came out: I can track pitch shifting, or recognize melodic patters, many interactive.. “destroyable” objects went into scene.. from cars, to helicopters, from giant radars to trains.

If you destroy a helicopter the pilot jumps out and parachutes, running away when on the ground.

Important: NOBODY GETS KILLED in this game.. humans flee (if scared). the player can interact or destroy quite everything.. but no live gets killed. It was my decision on nonviolence.

To start I wanted to design just one level, adding several different missions in the same environment (like: destroy all helicopters, roll the giant ball, push 10 buildings… turn on the Vulcano): one level, several mission, fast more fun.

Then we added the “blast lab”, because a giant doesn’t emit only sounds… many other things can be emitted.. but this is part of the surprise (which the player has to discover by himself)

Conclusion

I had never designed a full game, and this experience was (IS, I haven’t finished it!) very interesting: I could put into this project a lot of knowledge i collected and experienced in latest 20 years (from music to psychology, from programming to design, from marketing to symbolism and allegorics).

In next article I’ll talk about the first months of development! Stay tuned!

You can follow Tonzilla development at tonzilla.com or Twitter or Facebook.

Social Share Toolbar

Game Development with Unity 2D – part 5: A grid of Roman centuriae

This is the fifth part of a voyage in Unity 2D development, where we document in video the design and development of a simple strategic game reproducing the Battle of the Teutoburg Forest; here we make a more general discussion of grids in games. If you missed them here are Part 0, Part 1, Part 2, Part 3, Part 4.

We’ll dedicate this episode to discussing grids, which are at the core of so many 2D (and 3D) strategy games.  Up to now our battle has been in continuous space, but it would be cool to have a grid so we can more easily create an AI with a strategy. [Read more…]

Social Share Toolbar

Game Development with Unity 2D – part 4: Oplites, Back to Basics!

This is the fourth part of a voyage in Unity 2D development, where we document in video the design and development of a simple strategic game reproducing the Battle of the Teutoburg Forest; here we take a quick detour. If you missed them here are Part 0, Part 1, Part 2, Part 3, Part 5. [Read more…]

Social Share Toolbar

Game Development with Unity 2D – part 3: GUI, or No Text is an Island

This is the third part of a voyage in Unity 2D development, where we document in video the design and development of a simple strategic game reproducing the Battle of the Teutoburg Forest. Here are Part 1, Part 2, Part 4.

Video

In this part three we are going to have health bars, labels and winning conditions; here is the video (also directly on YouTube watch it in HD for a better experience): [Read more…]

Social Share Toolbar

Unity Audio: Concepts and Plugins – DAG pod 15

Images from Krur's studio

In this short but dense episode of the Design a Game podcast, we talk with musician and developer Stefano Cecere @krur about audio in Unity. Listen carefully because if you are beginning to use audio in games here you can quickly get several hints. [Read more…]

Social Share Toolbar