Blog, Unity, code

Getting started with Unity3d at Freeplay 1014 Aug

So. I gave a talk to day at Freeplay 10 all about Unity3d. I thought it was a bit scattered and I only got through about half of the stuff I wanted to get to (I didnt get to coroutines!! they are very important!) However, the audience was absolutely awesome and they ask really fantastic questions and it was a very interactive and fun session. Also, it was totally packed.

People were sitting on the floor and the room was about 35 degrees (that is 35 degrees C, for those of you in the states, that is approximately a million degrees fahrenheit). But all in all it was pretty awesome.

For anyone just tuning in, the talk started out with a quick tour of the unity interface, then I basically dove right into building a game prototype from scratch, trying to get it done in just over an hour. It was a bit of a frenzy of code and components and general Unity awesomeness. Well, I ended up only getting through the creation of a plane that you could fly around and shoot stuff and crash into things and exploding. That is as far as I got :-) I did not make ti to enemy turrets, or procedural city generation. However, as I mentioned earlier, there were so many good questions that I probably covered more actual material than I had originally planned.


(This is the prototype game using the frogames buildings, roads, textures and the plane)

Anyhow. Since the talk was all about prototyping, I was using the totally fantastic and incredably inexpensive protopack from frogames. These guys have a handful of unity compatible content packs that are absolutely worth every cent in terms of time saved and making it so easy to just grab a few prefabs, throw them into a scene attach a few scripts and you have your game idea outlined and ready to tweak.

However, I want to be able to give away the project, but I cannot give away the protopack... sooo I went in and stripped out the proto pack stuff and replaced it with primitives. It doesnt look as nice, but it still does the job, and you can get to the scripts and have a play with all the stuff I talked about today.


(this is the non-awesome looking primitives-only version of the project, which you can download)

So anyway, here is the Freeplay project sans protopack stuff.

SO: here is my advice: go and buy the protopack, it is only like $15 or something stupidly cheap. Then go and build your prototype game.

Let me know if you have questions or whatever!

Cheers!
-B

BBTouch, Unity, code, multitouch

New uniTUIO CE scripts04 May

Hello everyone!

Thanks to anyone who stopped by the Unity3d booth at GDC and said howdy to Sandor and I and checked out the multi-touch table: the FishTish.

As promised, the updated uniTUIO scripts have been made available on the xtuio.com site!

They have actually been up for quite some time now, but I ahve been (as usual) either too busy or too lazy to get a post up, so here it is:

Note: they have been pretty much fully redesigned to take advantage of the 'iPhone Input' style of touch detection.

What does this mean? Well, the older scripts used a more centralized raycasting and distribution method. There was one main event handler that took each touch point and checked to see if it collided with any registered 'touchable' objects. This is a perfectly good design, and it works very well when you have lots and lots of points (in other words, you are only raycasting once per touch per frame)

However, we decided to go away from that and create a fake iPhoneInput class that you can access from the desktop version of Unity.

Why?

Well, the most compelling reason was so that we could quickly and easily port iPhone apps to the touch table. Once I had the faux iPhoneInput class that was being populated with TUIO generated touch information, then it was trivial to take a few of the iPhone apps (and most all of the Unity iPhone tutorial projects) and simply drop them in and have them 'just work'.

In fact, funny story: On the first day of the GDC expo, I had another Unity/iPhone dev come up and he was excited about the FishTish and thought that his app: iPottery would work really well on it. I grabbed the code from him with the intention of dropping in our scripts and installing it as one of the demo apps on the FishTish. Well, that day was quite a long one and I did not have the energy to actually do anything with the script until the next morning. I spent approximates 15 minutes with a totally unfamiliar code base (iPottery scripts are all in JS and the uniTUIO stuff is all in C#, so that also speaks to how simple it is to use them :-) and I had it working no problems. I spent most of my time deleting the onGUI stuff (onGUI doesnt work with uniTUIO, soory!) and adding some guiText/guiTexture based buttons instead.

For the next two days of the expo we showed off iPottery along with all the other demo apps and it worked great!

Ok, enough of my tangent, how does this actually work?

Well, grab the sample project from the link above, there are two scenes, one called 'basic touch' and one called 'buttons'. Buttons actually contains the entirety of 'basic touch'. (it just has more buttons in it)

Effectively what the new scripts provide is am iPhoneInput class that you can use in your TUIO enabled MT apps just like you would if you were writing an app for your iPhone or iPad. I have provided a dozen or so scripts that show some examples of how to use the iPhoneInput to do things like basic drag/scale/rotate and build buttons using either GUIText/GUITextures or 3d objects.

I havent had time to put together a video yet, but the code is pretty easy. The only thing that you will need is to make sure that you have an active BBiPhoneInputManager script running somewhere in your scene.

I use the BBTouchManagerStarter script to check to see if there is already an input manager and if not then make one. This is good because if you switch scenes, the input manager does not get destroyed. In an actual deployment, you can just instantiate one in your opening scene and be done with i, but during testing when you want to be able to just look at the scene you are in, this can become cumbersome, so I use the BBTouchManagerStarter in all my scenes instead.

Cheers!
-Ben

BBTouch, Blog, Unity, code, multitouch

it’s a uniTUIO Xmas25 Dec

It is xmas morning here in oz, so for those of you who celebrate that sort of thing, I hope you are having a fun one! For everyone else, I hope that the wintery holiday season is similarly lovely for you as well.

In any case, I managed to stay up very very late a few nights ago and went through the Molecules codebase and extracted the essence into what we are calling the uniTUIO community edition.

If you have not heard of this before, the basic idea behind uniTUIO is to have a nice set of scripts to allow you to easily implement TUIO based multi touch input into any Unity3d application.

If you dont have Unity3d or dont know what it is, then you really should go to www.unity3d.com and get a copy. It is crossplatform and the basic version is free (and it really isn't very basic, I built a couple complete games using that version (back when it was called the indie version)).

Anyhow, the home of uniTUIO is at the xTUIO.com website. Ultimately I will be publishing posts like this one up there, but for now, since it is still early days and not that many people know about xTUIO.com I will post this here and have sandor crosspost it there.

Currently the uniTUIO CE is comprised of a unity project which has a couple basic scenes and a couple dozen scripts. Also, I made a couple videos showing how to use the various scenes.

There are two basic methods to get at the TUIO event information.

The first one, which is used by the BBCrosshairController and BB3dCrosshairController scripts, is a simple polling method. These scripts have access to all of the touch information for the entire surface and can act accordingly.

These scripts call up to a singleton script: BBTouchEventManager. It is the touch event manager that actually takes the TUIO information and converts it into a BBEvent object, which basically means that it converts the information from TUIO form into a Unity friendly format.

If you are building a 'traditional' sort of unity game where you have a central character that you are controlling, then using this polling method makes sense. This is basically the same thing as using the Input class in unity or the iPhoneInput class in Unity iPhone.

One example of this is the particles scene which uses a script called the BB3dCrosshairController which polls for all available events and spawns a particle system under any touch events. using this method you can replicate all the fun 'fire from the fingertips' sort of MT demos in about 3 minutes. (or longer if you are like me and love to just tweak the particle systems for ever and ever to get them 'just right'. Note: the particle system that I did for the examples is not 'just right', i just threw some values at it so that you would have an idea of how to do it yourself)

Picture 4

However, in many multi-touch applications you tend to have dozens and dozens of objects in the scene that all need to be aware of any touch events that are interacting with them. In this case it does not make good design sense to have each and every object grab a copy of all the events and try to figure out if any of them apply to that specific object. Instead we have a central distribution point that checks the incoming events against the scene full of objects and sends out event messages as appropriate.

This is where the BBTouchable scripts come in. The BBTouchEventManager takes the raw TUIO events and raycasts through the scene looking for any objects that are both in a special 'touchableObjects' layer and have a BBTouchable script attached to them.

The BBTouchable script provides some overrideable abstract touch input handling methods. For the most part, when doing MT apps that deal with lots and lots of different objects that need touch inputs, you will be subclassing BBTouchable to get your custom functionality.

In the uniTUIO scripts I have made a few example subclasses of BBTouchable. one is called BBBasicTouchManipulation, and it provides any object with the basic single touch to drag/double touch to scale and rotate gestures that are very common in MT apps.
Picture 2

The second one, BBTouchableButton shows how you can make a button that lives in 3d space and reacts to touch events.
Picture 3

You should have everything you need to get started with Unity and TUIO now. If you have questions, dont hesitate to comment here or on the xtuio site, or email me directly, or pm me at the unity forums, or whatever.

Cheers!
-b

Blog, Unity, iPhone

Mole at GCAP: Very well received!09 Dec

(Note: this is cross posted from Escape Factory)

Chris and I just got back from the Global Connect Asia Pacific game dev conference here in Melbourne. We entered Mole into the GDAA Independent Games Awards 2009 and got selected as one of the finalists.

As a GDAA finalist we were invited to put up a table and show off our game at the conference. Chris whipped up a few posters and I grabbed a couple of the stray laptops that I have laying around and we hit the expo.

Mole_Icon_125x125

GCAP is not a gamer expo, it is a game developer expo, so all the people there are somehow involved in the creation of games. Over the two day expo, we spoke to a zillion talented and creative people and they all played Mole, and let us know what they think.

The response was overwhelmingly positive. We had people coming back two and three times to just sit and play Mole during the downtimes. We had people who just sat down to have a quick look end up staying for 30 minutes trying to dig deeper and deeper.

Best of all however was the ability to watch people play the game. We spent a huge amount of time before the conference making sure that the core game play was solid and that the game was fun, and we were richly rewarded for that effort. However, watching people play the game highlighted the areas of the user interface that were lacking. It made apparent the places where we need to change the words on the menus or add new buttons. For instance, when you go to the upgrade shop from the end-of-dig scorecard, it is not at all obvious how to get back. Similarly, when people play it for the very first time, they run out of air and get back to the surface and don't realize that they need to hit the 'finish digging' button to end the dig so they can start a new one. We even found a few gameplay bugs that we will iron out.

We are currently going through and tweaking all these little bits and pieces to try to hone the user experience before we release it to the app store. But we want people to play the game so I have put up the GCAP version online so that anyone can play it for free.

If you are into it: head over to the Mole page and hit the 'play now' link. You will need the Unity3d player, and you can get it from the game page.

Mole_Icon_512x512

We are planning on keeping the online version free to use, and we will be updating it alongside the iPhone version, so if you come back and notice some new tweaks here and there, that is why.

We love to hear what you have to say about the game, so send me an email, or leave a comment here!

BBTouch, Blog, Unity, code, multitouch

uniTUIO coming soon! no, really!11 Nov

Hello everyone!

Since we announced uniTUIO a few months ago, and entered a uniTUIO-enabled app into the Unite09 contest, there has been a flood of emails coming in asking me if we are releasing the uniTUIO source.

So! Here is the answer:

Yes!

But I have to find a few free hours to rub together to get the code into a useable and clean form. We set out with the goal of having a nice framework of scripts to make using TUIO inputs in UNity3d trivially simple. I think we succeeded.

uniTUIO was built during (and for) the Molecules project (which was really a half-dozen different media presentation applications). As the project deadline began to loom, making the Molecules apps became a bigger priority than preserving the purity and re-usability of the uniTUIO framework. As a result, I had to cut many corners in order to meet the deadline (which pretty much always happens) so the uniTUIO stuff is riddled with Molecules specific code which is neither generically useful, or particularly re-usable in any easy way.

So, I need to go back in and refactor the uniTUIO stuff to make it not suck basically.

However, I will explain to you what the uniTUIO stuff includes, so that you can at least not get your hopes up too much :-)

First off, at the low level, it starts with the c# TUIO/OSC implementation by Martin Kaltenbrunner, which everyone can get ahold of here: http://reactivision.sourceforge.net/.

On top of that is pretty much where uniTUIO starts. It is a collection of about a dozen scripts. There are a few static singleton 'manager' style objects that start up the TUIO scripts and listen to the events as they come in. These convert the TUIO data stream into some portable 'event' objects that include the local Unity environment information. (in other words they convert from TUIO screen-space to Unity viewport space).

Also there is an event manager that does raycasting into the unity scene and picks out any objects that are in the right layer (a 'touchable' layer) and passes the events onto those objects.

There are a few more scripts that are meant to be attached to touchable objects.
One is a high level touch event handler that accepts touch events from the event manager and applies them to it's gameObject in a generic fashion.
Inherited from that object is a basic touch manipulation script that provides simple gesture support to handle the basics like dragging, rotating and scaling a gameObject.

That is what uniTUIO includes. It is meant to be a simple starting place for you to be able to build on for your own MT projects in unity.

So anyway, we will announce it when we release it (hopefully sometime this month) so keep an eye on the RSS feeds. Cheers!
-B

ps: for those of you who are very impatient, have a look at this thread on the unity forums. User Jorgen posted a simple unity TUIO implementation project, which is a good place to get started.

About

meMy full name is Ben Britten Smith.

I go by Ben Britten because Ben Smith is a bit too common and using my full name is a mouthful.

I live in Melbourne, Australia and service clients all over the globe.

Contact

Have some questions?

Feel free to contact me directly at support@benbritten.com with any questions you might have about any of the applications I support.

Thanks!

PHVsPjxsaT48c3Ryb25nPndvb19hYm91dDwvc3Ryb25nPiAtIGFib3V0LXdpZGdldDwvbGk+PGxpPjxzdHJvbmc+d29vX2FkX2JlbG93X2ltYWdlPC9zdHJvbmc+IC0gaHR0cDovL2JlbmJyaXR0ZW4uY29tL3dwLWNvbnRlbnQvdGhlbWVzL3ZpYnJhbnRjbXMvaW1hZ2VzL2FkNDY4LmpwZzwvbGk+PGxpPjxzdHJvbmc+d29vX2FkX2JlbG93X3VybDwvc3Ryb25nPiAtIGh0dHA6Ly93d3cud29vdGhlbWVzLmNvbTwvbGk+PGxpPjxzdHJvbmc+d29vX2FsdF9zdHlsZXNoZWV0PC9zdHJvbmc+IC0gYmVuYnJpdHRlbi5jc3M8L2xpPjxsaT48c3Ryb25nPndvb19ibG9ja19pbWFnZTwvc3Ryb25nPiAtIGh0dHA6Ly9iZW5icml0dGVuLmNvbS93cC1jb250ZW50L3RoZW1lcy92aWJyYW50Y21zL2ltYWdlcy9hZDMzNi5qcGc8L2xpPjxsaT48c3Ryb25nPndvb19ibG9ja191cmw8L3N0cm9uZz4gLSBodHRwOi8vd3d3Lndvb3RoZW1lcy5jb208L2xpPjxsaT48c3Ryb25nPndvb19ibG9nPC9zdHJvbmc+IC0gdHJ1ZTwvbGk+PGxpPjxzdHJvbmc+d29vX2Jsb2djYXQ8L3N0cm9uZz4gLSAvY2F0ZWdvcnkvYmxvZy88L2xpPjxsaT48c3Ryb25nPndvb19jYXRfbWVudTwvc3Ryb25nPiAt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