Physical Computing with Unity
Tinkering with electronics
A talk by Ciro Durán | @chiguire
This talk has speaker notes, press 's' to reveal them.
Hi, thanks for checking out the slides! Hopefully the notes will give some context to them. Please write to me if you have any questions on the talk.
These are slides for a talk I was going to do at the Brighton Unity Usergroup in March 2017. Sadly, two days before I was going to give the talk I sprained my ankle in a very bad way, and I was unable to move for a couple of weeks. Thus, I had to cancel it. However, the slides were done, and I think they're useful for those that don't know what physical computing is. So here they are.
Hi, I'm Ciro
You can pronounce that as the number zero , go ahead, that's fine.
I work in the games industry, doing lots of stuff.
Today's topic: Physical Computing
Does this term mean anything to you? How many of you are actively tinkering with it? How many of you are actually earning a living from it?
Computing and electronics are separate worlds
For us all game developers: computer and electronics are separate worlds. Electronics deals with physics phenomena, while computing deals with our own world built over maths. A one is a one, and a zero is a zero.
Physical computing bridges that gap
Physical computing bridges that gap, by providing a simple interface to deal with electronics, while still being able to program. Instead of libraries, we got accesories we can plug in very easily and use very quickly.
Who's doing this kind of thing?
There's people working on this, working with the ideas that are enabled by physical computing, not necessarily in videogames. I'm going to show a couple of examples as a matter of inspiration.
Cirque du Soleil
Taken from kent_caldwell 's instagram
Kent Caldwell is an artist, usually does sculpture, but he also provides the electronic elements in Cirque du Soleil's performances.
Simone Giertz
See her videos
Simone is the self-proclaimed "Queen of Shitty Robots", and has used this persona to experiment and have fun with outrageous ideas for robots.
Robin Baumgarter
Taken from his website
Robin is a Swiss game developer based in London, he's the one that has pushed most the idea of games with physical computing. A great reference.
NIME community
Taken from NIME conference video .
NIME, or New Interfaces in Musical Expression, is a community that focuses in inventing new musical instruments or augmenting old ones. They base a lot of their work on physical computing.
Things I've done
A Consensual Hallucination (as collaborator)
I don't have a huge or impressive portfolio as these fine guys, but I've done a couple of things. There's a project I collaborated with some Raspberry Pi programming and electronic setup...
Things I've done
VIDEO
Lilibeth's Parade
...and a game made at the Global Game Jam 2017.
What will we use?
Raspberry Pi
Electronic prototyping boards
Our own PCs
There are many things that could be considered "inside" physical computing. I'm going to mention two. First, the Raspberry Pi, and the we will talk about electronic prototyping boards. We will also require our own PCs for development. There is some programming involved, after all.
Raspberry Pi
A 30£ credit card sized computer
ARM processor
Decent GPU
1GB RAM
USB ports
GPIO port
Camera and display ports
There is a lot to be said about the very succesful project from Cambridge. It's a fully-operational computer, runs Linux, has access to electronic components through its GPIO port. It is possible to show high definition video flawlessly through its HDMI port. You can also plug a camera which is very fast, and do things like computer vision. The Raspberry Pi has no storage, you need to plug a microSD card, which holds the operating system. The Raspberry Pi Foundation offers a custom Debian-based image called Raspbian, and an easy installer for it called NOOBS.
There are other models of the Pi
Pi Zero (and Pi Zero W)
Raspberry Pi 2
Compute Module IO Board
And also accesories (called HATs)
There are quite a few models for the Pi, depending on your computing needs. Some of them have a smaller size, like the Pi Zero. They also require less power, which allow you to plug it into a battery for a longer time. A regular USB power bank is enough for powering these, but the time it lasts depends on its capacity. There are also computer module IO boards, which are simply for embedded applications, you might ignore these for the moment. There are also some accessories you can plug to the Raspberry Pi through its GPIO port, these are usually called HATs, for Hardware Attached on Top. These allow you to have easy pluggable electronic components.
Can you run a game made with Unity for the Raspberry Pi?
Not officially. But this seems an interesting alternative!
This is an interesting question. Unity officially does not support the Raspberry Pi. The Raspberry Pi runs on an ARM processor, so currently there is no way to build a game in Unity directly to the Pi. However, there are certain experiments with running Android on the Pi, and then build the game for Android. However, the Pi doesn't have the hardware drivers for Unity. This is a shame, as Unity could certainly be used by artists and run their stuff in this little machine. Currently Artists use Processing, or OpenFrameworks to make their stuff.
Electronic prototyping boards
Now onto electronic prototyping boards. I've chosen this name rather than call everything Arduino as lots of people do, since Arduino is just one of the many brands lying around. It's made an impact, and is currently an standard for many things, but there is still some work to do, and other brands that make good stuff as well.
Arduino
However, you might not know that yet, so let's start with Arduino. Arduino set a standard in the way to program microcontrollers. You can use the pins as you see fit, and there are quite a few accesories for it that makes it way easier to program stuff. These accesories are usually called shields. You program the microcontrollers with the C language, and these programs are usually small.
Adafruit Feather
This is one of the very well known alternatives to the Arduino, the Adafruit Feather, with 3.3V architecture. You have to consider the voltage you use when you make an electronic project with these components. The pins in the Raspberry Pi are 3.3V, whereas the ones from the Arduino are usually 5V. You have to make sure if the component you use supports the correct voltage, or your project might not work, or you might damage the component or the board.
What can we sense with electronics?
Capacitance
Light
Colour
Sound
Proximity
Temperature
Humidity
An example of an Arduino sketch
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Another example of an Arduino sketch
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
So where does Unity come into play?
We can use the Serial port from .NET to communicate with the Arduino
We can also use the Arduino as a Joystick! (HID)
Or we could use it as a MIDI interface (it could require extra costs)
Setting it up
We can use the Serial port from .NET to communicate with the Arduino.
In Unity you need to change a setting: in Edit -> Project Settings -> Optimization -> API Compatibility Level make sure you select .NET 2.0, and not .NET 2.0 Subset. Otherwise the project won't be able to locate the Serial object and won't compile.
ArdUnity could make it easier
ArdUnity allows to create Arduino sketchs throught its Wire Interface. The programs you create visually are compiled to the Arduino's own IDE, you still need to upload it through there.
Why bother with all this?
I’m tired of games in their current state. I’m tired of controllers and screens. Yet… I still love games. We all love a good experience, in which we can live other lives. That’s what literature does, it makes us live other lives without a huge investment of our time. Let’s rethink the way games work. We might not be able to scale cheaply our sales with Steam, given the current over-saturation of games. Let’s go back to local, and work with the ones next to you. Think about the ways you could make a game when you take the usual controller off.
We still need something
Lots of developers are so afraid of this they don’t think in other terms than the common input methods: keyboard, mouse, game controller, or VR. I don’t blame them. The most difficult part of introducing these methods is enabling users to be able to communicate their actions as effective as possible to the game (this is when the controls in your game “feel tight”). But in order to do this, you need that the users acquire some literacy on the method they use. The literacy is usually not acquired overnight, and it often has to come with some leverage from another field. This is basic UX. Many years and iterations of game consoles have brought us the game controller. But when you break out of the mold of game controllers, you might feel quite naked, even if you manage to do something decent. The answer is to look at what people already know they do, and do something that looks pretty much like the thing they’re doing. It doesn’t matter if it looks dead boring, or made from rote memory. Programmers play a game about programming, just because it sweeps away the boring parts of the job (i.e. meetings) and puts you right in the meaty, juicy part of our jobs. I hope you really are watching the next thing for videogames from outside of videogames.