Getting caught out by c# in Unity3d and Smartfox

Warning a moderately techie post with no pictures.
I have been a programmer since I was 14 and I have used an awful lot of programming languages and danced around many a syntax error. When you do spend all day everyday in a particular environment the basics tend to just flow, when you chop and change from code, to architecting to explaining and sharing with people, sometimes the context switch gets more tricky. Todays tech world is also full of many flavours of component that we wrangle and combine. There were two in particular that were causing me hassle and I needed to look up more than once so I figured if I am having the problem then so will someone else 🙂

Up to now most of the things I have done in Unity3d with various experiments use the basic examples and provided scripts or variations on them. These are all in Javascript or the .js deriviative that Unity uses.
However, now that I am talking to the Smartfox server pieces it’s become more useful to to do .cs (C#).

The first is calling a script in a function on another object in the scene.
In .js its straight forward
GetObject("RelevantObject").GetComponent("AScript").DoWork("passingingvalue");

Where there is a .js file called AScript with a function DoWork in it accepting a string. Attached to the object “RelevantObject”
It is just regular dot notation method access
(I know that it is no efficient to go and find the objects and components everytime but it is easier to illustrate the point in a single line)

In .cs its nearly the same but….
BScript someScript = GameObject.Find("RelevantObject").GetComponent();
someScript.DoWork("passingingvalue");

Where there is a BScript.cs file attached to “RelevantObject” but being c# is is not just the file name but a proper class definition.
So going from the quick lets just get this done of .js you have to be a bit more rigorous though it all makes sense 🙂

using UnityEngine;
using System.Collections;

public class BScript : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

public void DoWork(string sval){

//do something with sval
}
}

The other problem I had was more related to using Smartfox server.

I was attempting to set Room Variables. These are server side containers of information that when they change will generate an event to clients that have registered an interest. i.e. very handy to preserve the state of something and send it to multiple clients. The main smartfox Unity Island multiplayer demo uses more direct message to send position transforms for players.

It worked setting the variables, and I could see them in the Admin client. I also got the change message and the name of the variable(s) that had altered, but I kept getting exceptions thrown in the getting of the variables.

After a lot of hacking around it seemed that
room.GetVariable("myname"); //doesn't work
room.GetVariables()["myname"]; //does work

i.e. Get the whole hashtable with GetVariables and reference it directly versus getting the GetVariable function to do that indexing for you.
Now this may just be a wrong version of an imported DLL somewhere. I have not built the entire Smartfox Unity3d plugin again. It does work, so this may be a work around for anyone who is having problems with Room variables. It works enough for me not to worry about it anymore and get on with what I needed to do

Other than that its all gone very smoothly. Smartfox Pro (demo) does what I need and then lots more. I have had conversations and meetings with people in my own Amazon cloud based instantiations of unity powered clients. Now I am over any brain hiccups of syntax again its onwards and upwards.

Look just how simple things can be. Unity3d accessing the web

I have been doing a lot of Unity3d with data flying around, but I am still amazed at just how easy it is to get things to work.
For the non-techies out there this should still make sense as its all drag and drop and a little bit of text.
So you need a web based walk around some of your flickr pictures?
Unity3d makes it very easy to say “create scene”, “add terrain”, “add light”, “add first person walker (the thing that lets you move around” and finally to say “create cube”.
It is as simple as any other package to create things, just like adding a graph in a spreadsheet, or rezzing cubes in Second Life.
Once the Scene is created is it very easy to add a behaviour to an object in this case this script is types in and dragged and dropped onto each cube in the scene. (its in the help text too)

var url = "http://farm3.static.flickr.com/2656/4250994754_6b071014d4_s.jpg";
function Start () {
// Start a download of the given URL
var www : WWW = new WWW (url);

// Wait for download to complete
yield www;

// assign texture
renderer.material.mainTexture = www.texture;
}

Basically you tell it a URL of an image, 3 lines of code later that image is on the surface of your object running live.
The other thing that is easy to do is drag a predefined behaviour of “DragRigidBody” on the cube(s). Then you get the ability to move the cubes when they are running by holding onto them with the mouse and left click.
UnityScreenSnapz001
UnityScreenSnapz003

Now the other clever piece (for the techies and programmers amongst us) is that you can create an object of collection of objects and bring them out of the scene and create a “prefab”. This prefab means that you can create lots of live versions of an object in the scene. However if you need to change them, add a new behaviour etc you simply change the root prefab and the changes are inherited by all the prefabs in the scene. You are also able to override settings on each prefab.
So I have a cube prefab, with the “Go get an image” script on it.
I drag a few of those into the scene and for each one I can individually set the URL they are going to use. All good Object Orientated stuff.
This is not supposed to be a state of the art game :), but you can see how the drag and drop works and moving around using live images I drag in from my Flickr in this sample
Click in the view and W and A moves back and forwards, left click and hold the mouse over a block to move it around.
Downward gravity is reduced (just a number) and of course the URL’s could be entered live and change on the fly. I only used the square thumbnail URLs form my Flickr photos so they are not hi quality 🙂
This is also not a multiuser example (busy doing lots of that with Smartfox server at the moment) but it is just so accessible to be able to make and publish ideas.
The code is less complicated that the HTML source of this page I would suggest. Its also free to do!

Virtual Nightclubs, mainstream SciFi and digital legacies

Last night saw the airing on Sky 1 here in the UK of the Battlestar Gallactica prequel Caprica. BSG was a fantastic series, and was seemingly accessible science fiction throwing in a hint of West Wing.
The first 2 episodes really set up the story as you would expect but I was not expecting the subject matter to resonate quite so much with some of the real world virtual work that we are all doing.

Caprica is set fifty or so years before BSG on a distant resembling earth in many ways. In the first programme a group of teens are engaging in attending v-clubs. Virtual night clubs. These clubs are an underground movement and accessed using a headset “holoband” to inject the photo realistic images into the users head. The places themselves are portrayed as a wild noisy and dangerous night clubs, hidden from parents knowledge.
band
One of the teens is the daughter of the richest man on the planet who happened to invent and create lots of the tech. She has created a clone of herself inside the virtual environment. Everyone has a physical clone, they showed the use of body scanning in a booth to get physical parameters, but this avatar (and they us that word a lot) is an artificial intelligence construct.
When the real teen is killed her AI lives on in the virtual world. We get to learn that she did not simply download here brain data to a computer core (an often used idea), but instead the AI learned who it was to be the girl through the digital trails that she had left during her life on the world. In this environment indicating that the algorithms to search and learn were clever enough to reconstruct and then move forward as a person.
The father then seeks to perform what can only be described as a Frankenstein manoeuvre, and attempts to place the AI data into a physical manifestation of a robot, or Cylon. The digital is made real.
Clearly this mainstream science fiction is informed and extrapolates todays science fact. The digital trail we leave today may not yet be enough to reconstruct our personality, but those of us who choose too are certainly leaving lots more clues as to who we are and what drives us than ever before. There are also clearly times when people’s echoes are placed out in the public domain when they did not intend them or want them to be.
I was also reminded of a interesting question I was asked when presenting at a recent conference. “What happens to your virtual presence when you die”.
OK, so we don’t quite inject virtual worlds into our brains matrix style, we don’t have fully functioning AI’s or autonomous robots to download into, but we do have ways to interact online and share who we are and what we think and do. When we no longer participate in the online experiences we still have left a legacy and digital echoes, it’s not just photos and memories anymore.
Of course just as with the film Avatar we may find a large number of people not exposed to current virtual world technology may be a little disappointed but equally many may see these parallels and start to understand the deeper significance to our online presence and why so many of us are so passionate about them.

Performance bell curves don’t work!

Towards the end of each year and start of the next many people in “serious businesses'” seem to have to suffer the torture that is the annual performance review. Not having to deal with this ridiculous set of processes this year has not kept me away from it. I still see the unfortunate side effects that the various systems used have on people, their morale and their sense of belonging to an organization.
What tends to happen in most large companies is that they have decided that everyone should be measured against some set of targets. (That sort of makes sense). They then decide that clearly some people will be better at things that others. (Another correct assumption). They then decide that a bell curve should be applied to the performance of people. i.e. lots in the middle of the road and some great people at one end and no so great at the other. (This also makes some sense).
Then the logic goes out of the window in favour of process.
The bell curve is not applies across the entire population at once. Instead it is broken up into bell curve copies with equal weighting and applied to nominal collections of individuals, such as a department. As each department and individuals actual objectives are probably different the relative performance and the bell curve are in effect blown to pieces, like for like is not easily applied.
Various groups of individuals may have champions in the political systems who fight for a greater share of the bell curve, but many will instead try and fit the bell curve onto their people then attempt to justify their decisions.

A whole heap of time and money is wasted in many large corporations in order to ensure that the status quo is maintained.
I have experience all ends of the spectrum in these evaluations. If you get an outstanding result you feel great, but also slightly guilty. Very few people will take people to the pub to celebrate their “outstanding” performance rating.
Those that get the next level down (typically there are only 4 or 5 ratings) feel sort of happy, but annoyed at being so close yet so far form being told they are great.
The next rating is really “yep you are just about doing you job” thanks very much for that!
The other ratings are typically supposed to be a wake up call of some sort, or a threat, or “well its just your turn”. The slightest reason can be used to reduce someone to a low performer. I have heard and experienced enough aberrations in the process such as the particular dichotomy of receiving some of these ratings dressed up as business but knowing they were personal and possibly bullying, to know that the systems used are damaging in so many ways.
So what does a company achieve by attempting to centralise and control the distribution of performance?
Well they force most people to be mediocre, and hence the company to be mediocre.
Once thing social media has taught us is that even the most mediocre employee in a company can have a huge impact on the direction of the business. So surely it is time for the HR departments to find some innovation somewhere?
This is not to hide from competition and merit, but to actually put that back onto a footing where it means something.
I have to consider these things even more deeply in how the companies I am helping create, that I work with and possibly for deal with people.

The virtual revolution has started

This weekend on prime time BBC2 TV saw the first part of the four part documentary “The Virtual Revolution”. It is hosted by Dr Aleks Krotoski know to many of the metarati out there for studies into Social Influence in places like Second Life, and also the living the rock and roll with Jim “Babbage Linden” Purbrick and Max Williams in the band 100 Robots. Many people will have followed the #phdhell that Aleks has been tweeting about too. Also the twitter stream has been full of the production of this programme.
All this leads to the fact that it was a much watch piece of TV. I tweeted early on “This is what we have the BBC for” because it was a very well made, not too geeky and well thought out exploration of “The Great Levelling”. Many notable shapers of the web we know today featured in interviews. It will hopefully be seen by many people who seem to assume the web and social interaction and sharing of information is some how a bad thing. It isn’t. It has arrived and we have changed many of the the things we do and enhanced others by engaging with one another.

feedingcaves2image.022
I should add that whilst the programme covers the past 20 years it should be clear to us all that we have come a long way and still have a long way to go in human communication online. It starts by embracing what we have now, to engage and explore all the possibilities. (Yes that includes virtual worlds like Second Life!). However don’t assume we have the perfect solutions yet. There is more to come than avatars, islands, Facebook friends, blogs and twitter. An underlying social change is happening though.

To quote Stephen Fry in one of the many pieces of video available on the Virtual Revolution website “we are, constantly in need of, of connecting with people for, friendship, love, sex, knowledge, growth, enmity, territoriality all the, all the imperatives that drive us as human beings. Erm we’ve created villages and towns to help us do that and roads and now we’ve created something else that allows us to do it, us to do it even more. ”

For a slightly more reactionary piece there is always John Perry Barlow on freedom of expression (who I nodded in agreement a lot with)
“I wrote a piece for Wired Magazine in, in ’93 which they called The Economy of Ideas. And I recognised that the only reason that copyright had worked was because it was hard to make a book. And that suddenly anything that a human being could do with his or her mind would be infinitely reproducible at zero cost and infinitely distributable. And given that there is a fundamental quality in human nature that likes to share information. I mean if you think something is, is cool or interesting what’s the first thing you want to do with it? Tell everybody you like. You know, and if, and if it’s not just simply saying I read this great book you should go out and buy it but you can just sort of zap the book right in to the other persons mind practically, you’re gong to do that. And you’re not going to have much regard for, for copyright. Er, and so the powers that had been suddenly saw copyright as being a splendid way to control this scary new liberty. Er, that exerting powerful controls on owned word would be the, would be the real method of clamping down on this, this thing.”

One interesting thing that happened on the starting titles, and helped the twitter buzz was seeing on screen the hash tag for #bbcrevolution. It was just placed bottom right of the screen. For many people this will seem alien, “thats not a URL”. Whilst the general public, non tech geeks, have got very used (in the past few years) to seeing a web site URL they will not have seen the meta URL that is a hashtag. The #andsometext notation is used to lift a tag or label a piece of conversation as being relevant to a subject. It is platform agnostic, you can hashtag anywhere, its just text. It means searches can find threads of conversation across disparate sources. It is not organised, controlled nor policed. It just is. To see it on a documentary that has been create through many online collaborative efforts, putting its money where it mouth is is another indication of the validity of the programme.

Sports communities in Second Life – A new satellite dish?

With all my comments on needing to engage with virtual worlds and the olympics and the work I have done up to now with online sports representations is it really great to find an exemplar of a community driven collect of sports enthusiasts.
One great example is the Global Online Hockey Association
Hockey SL Style
In particular it is worth taking a look a Treet.Tv coverage of a live event held there on Jan 10th
Now there is a lot of passion and effort, plus community participation that goes into this, but when you think of the global budgets of the advertiser and sponsors of world sporting events this really is not very expensive! The same applied to Wimbledon in SL, which in reality I paid for the land and a few of us volunteered our time to build.
It is the fact that people with an interest and a passion can get an awful lot done themselves. However think about how all this could be made even better with just a little attention from an interested party.
For sports social media and virtual worlds need to enagage, for virtual worlds what could be more mainstream an example than sports? Much of the take up of Satellite TV in the UK was driven by people wanting to watch soccer.
Can virtual worlds and online interaction be the new Satellite dish?

The future of learning? Wake up to virtual!

This week I have been to two events related to learning and education.
The first was eduserv’s final get together on where next for virtual worlds. The entire audience was made up of experts and evangelists and practitioners of virtual worlds across lots of UK universities. As a body of people and experience it was very heartening to be in such a gathering. Given much of what I have been doing recently has been education related it was good to know there were so many of us.
Still however there was the pressure for many that this was seen as some strange art form and hobby sideline. We battle on though as we do know this is the right thing to do. It is not just the technology that needs to be accepted though. The main battle is challenging ways of doing things that are accepted practice and in many ways easy and lazy for people to change. e.g. rolling out another ppt lecture to a group of students forced to sit in a room an listen. Daniel Livingstone from Sloodle used a picture from the middle ages of a lecture theatre. This showed there are deep rooted patterns in education that can still be used but improved with a little bit of thought and willingness.
The second event was the Learning Technologies 2010 expo at Kensington Olympia where there were over 130 exhibitors in learning technology. Great ! It was a huge trade show to go to and full of experts in this field.
BUT!!!!!!!
With only a very few exceptions I was struck by the number of filling in form based applications, not even all Moodle. Lots of putting powerpoint and video and documents into “elearning” courses. Lots of “evaluation” and criteria based systems. Where were the virtual world learning platforms, even the serious games. Where was the deep rooted use of social media?
I was surprised and dismayed, followed by not being surprised again at the lack of more forward thinking technology and social solutions. Most people I talked to were surprised at what can be done with a virtual world, and they were supposed to be selling to me really.
The expo and conference is running for two days and today there is a presentation by Mark Oehlert for the US DoD about all the virtual projects and clever things they have been up to. I know that is going to blow the audience away of all they are used to is forms and videos in “elearning”. It was good to catch up with Mark and with Koreen Olbrish from TandemLearning as we keep in touch usually but meet very rarely (the last time was 3DTLC in washington).
It was interesting that Koreen had recently written a post “Do Virtual World Evangelists Really Want To Go Mainstream“. The answer from this one is of YES! 🙂
The insular nature of some industries and cosy gatherings, doing things the way they always have been done really is human nature. I have already been push the fact that avatars and islands are not the end point. There is a way to go. However the way we get mainstream acceptance is (as Koreen points out) diving into places and industries and pushing things forward.
So I have to ask the question why was there such a small selection of game and virtual world related people at this show? It would seem there is a gap in the market. I was thinking I just should have had a generic metaverse stand and explained all sorts of things like The Coaches Centre (Using web.alive and moodle to work with sports coaches and their organizations) and the work I am doing at the moment in SL with instructional design etc. Invited some or all of the people from the eduserv conference to talk and share their experiences.
There was at lease one stand there though, Kevin Corti was there with Pixelearning, and I liked the fact they were actually stand 101 🙂
Another was Caspian Learning with Thinking Worlds which has a great way of allowing people to describe a scenario and generate a browser based game engine experience. Though these were single user stand alone ones.
Many of the others that had any rich visuals looked like they were more custom builds and effectively CG movies.
I am left back at the thought the games industry is still missing a huge trick here. Whilst the virtual world companies like Linden Lab explain the use of education in the UGC Second Life the games companies have fantastic tools and techniques for creating experiences, how script writers and level designers work with visual, audio and code production. There is a middle ground and place for the instructional designers and educators to make a huge impact.
Anyway I look forward to hearing how Mark’s pitch goes.
I will get back to my Opensim, Second Life, Web.alive, Unity3d, Moodle, Sloodle, Pivote and custom build meanderings and try and convert as many people as possible in as many industries. What do I know ?

Sculptors and 3d printing

On friday I had a trip to London, talking finance, equity shares, next steps for a major project all very heavy stuff. On the way back from the meeting one of my good friend and business partners and I stopped by at The Royal British Society of Sculptors on Old Brompton road.
The outside of the building had a reactive sculpture that opened mechanical umbrella type flowers that wound up the side of the building like a vine so I knew this would be interesting.
Inside the main exhibits were suitably technical yet artistic. One was the wearable tail, a robot fashionable tail that was really more like Second Life than south kensington. Others were water bubbles generated in a tank to create the shapes of numbers, which was a forerunner of the glowing ball structures that rise and fall with the stock market at the London Stock Exchange.
Out the back there were a set of design concepts for a competition that would be the next installation to replace the flowers out front.
I was immediately drawn to this model
3d printed model By Bruce Gernand FRBS
It was a computer designer 3d model that had been rendered using a 3d printer in order to be able to see the concept before it is rendered in full size aluminium.
So there I was in a sculpture society looking at a physical rendition for a virtual model that would become a full size one. That was the winner for me as you can imagine.
I left a comment that I would like to be able to share the experience of exploring the virtual model as well as seeing the physical model.
With HP doing deal with Stratasys moving into the 3d printing market this sort of thing will become a lot more common!

Crowdsourced digital recreation of Olympics 2012?

I managed to get this idea into a tweet of 140 characters. Which I guess means that its not too bad an idea and easy to explain. The original text was
“2012 olympics spectators to share their videos. Pump video into project natal. Mocaped events rerendered in vw. Bypass agencies”

Image from Konami Track and Field at arcade-history.com
To explain the how and the why of this a bit more now the elevator pitch is done.
The London 2012 olympics is a huge event that will be taking place in a world that is already heavily immersed in social media. People are already willing to take photos, share their experiences. A mass event like the Olympics will mean huge numbers of people sharing that experience from their mobile devices at the event.
On the other hand we have an event that has lots of international politics around it, huge sponsorship deals to guarantee coverage and to also pay for the logistics of the event.
We want 2012 to be the best games ever. However we are in a cash strapped world coming out of a major recession.
One of the things I have majored on over the past few years is the recreation of sporting events (and other training events too) from data and descriptions of the event. This is in part a technical interest but also one where I know that sport is understood by most people, so representation of sport in new ways helps them understand things like virtual worlds, social media and games.
I got to thinking that if the various bodies and rights management people controlling the Olympics flow of content and data have the whole thing locked down, negotiated and controlled but are not doing anything forward thinking now using the emerging technologies then we need another option.
A crowdsourced and opensource approach may just be one that at least demonstrates the potential power of the crowd covering the event.
The basic premise.
2012 a high percentage of people able to attend the olympics either on corporate tickets or paid for will have good mobile equipment, cameras etc. Network coverage will be good as it will be boosted for the event too. So there will be a vast amount of tweets, pictures, videos, streaming video, blog posts, facebook chat etc flowing in and around the events. That will of course not be as good as the TV company coverage but it will still have a great deal of potential.
Taking some of those images, videos etc and utilising technology to work out which athlete is where, what event was this, and even motion capture the individuals at events using Project Natal (like) technology means we have a great deal of data available to digitally recreate the games in the public domain. Its the sort of approach Photosynth takes to recreate imagery from mass use of digital media. To feedback to the crowds with data driven augmented reality applications etc. It is a little way out, but it is not impossible and there is a lot of technical and social innovation that can occur in the next 2 years with web, mobile, virtual worlds and games.
I think London 2012 needs a focussed and serious look at the things that can have a huge impact to the coverage and popularity of the games. The things I am considering here are homebrew ideas. They can be done very cheaply by anyone. Their is huge scope for something much greater to be done for very little extra cost and effort in the scheme of things by the powers that be.
Capture, Analyse, Recreate, Share. Yes CARS for the olympics.

Plato, a clever bloke.

I have seen this quote by Plato flying around a lot recently. It is particularly apt and correct when trying to help people come to terms with the benefit of gameplay in all fields.
“You can discover more about a person in an hour of play than in a year of conversation.”

Now bear in mind we have the ability to play and interact with one another on all sorts of digital channels. Social media is about conversation of course, but it is also the social side of gaming, be that a dedicated game or people choosing achievements that mean something to their friends and playing, competing and cooperating. e.g. unusual photo competitions on flickr.
Imagine too that we are playing multiplayer games. So you get to learn more about several people in 1 hours gameplay online than several years worth of individual conversation.
The amount that we reveal about who we are online through these gaming, and in the case of virtual worlds semi-gaming experiences should not be underestimated as a powerful reason to interact. The institute of the future has a post on Avatar Maximization around how people react to us and our digital representations.
This is not really just about identity, though its clearly a subject to consider as we see on New World Notes about real life versus made up vs augmented names. It is about what happens when humans communicate in ways other than purely talking face to face.
Discovering more about motivations, styles of operating and preferences do shine through in our gameplay. Games of all sorts help put people at ease and when at ease their true self shines through. Not all games of course, in poker the aim is to not give anything away and keep that poker face. However, the method by which you control your “tell” or discover others is equally enlightening.
I suggested in my predictions that Games as Work is a way forward and it would appear that Plato agrees (sort of).
It could well be that with fantastic creative tools like Unity3d and virtual world toolkits like Opensim we will indeed see even more “gamification” as David Helgasson Unity3d CEO has suggested
That can only be a good thing for understanding our colleagues, friends and competitors.