Asynchronous Serial Communication

In a previous post, How To Integrate Arduino With Unity, we have shown how data can be sent and received through the serial port. The main problem encountered was dealing with the latency and the delays that communicating across different devices introduces. The solution proposed in that tutorial used a coroutine; decoupling the device communication from the game logic attenuates the problem, but it doesn’t remove it. The main problem is that, despite the name, Unity coroutines are not really executed in parallel with the rest of the game. Unity, by design, is not thread safe. This means that true parallelism is intentionally avoided by the engine, as it could result in race conditions. To solve the problem of the communication between Unity and Arduino, once and for all, we need actual threads.

At the end of this tutorial, you can find a link to download the Unity package.

Continue reading

ShaderGUI: Custom Material Inspectors in Unity 5+

This tutorial explains how to create custom material inspectors for your shaders in Unity 5.

material4

This is a tutorial for Unity 5: Unity 4 used MaterialEditor (legacy documentation here) to customise a material’s inspector. That is now deprecated; you should use the new ShaderGUI (documentation here) instead.

Continue reading

An Introduction to Signal Smoothing

Noise is everywhere. Whether you’re sampling accelerometer data for a mobile game or trying to measure the temperature of a room, noise will be there. Even if you could remove all the noise from an input device, you’ll still have a certain degree of uncertainty. If a player has tapped on the screen, where did they really wanted to tap? All these scenarios forces to re-think about how we gather and preprocess data.

Continue reading

How to Simulate Cellular Automata with Shaders

This post will show how to simulate cellular automata using shaders. The popular cellular automaton developed by John Conway, Game of Life, will be used as an example for this tutorial. To learn how to set up your project, check out the first two parts of this tutorial: How to Use Shaders For Simulations and How to Simulate Smoke with Shaders.

life

Continue reading

Impossible Geometry: Non-Euclidean Cubes

This tutorial will teach you how to create non euclidean cubes in Unity, giving the illusion that each face is a door onto another dimension. This post is part of a series of tutorials on impossible geometries.

antichamber

This effect can be seen in many game, most notoriously Antichamber which uses it extensively.

You can download the Unity package here.
Continue reading

How to Write Native Plugins for Unity

Unity has the ability to import pieces of code written (and compiled) in other languages; they are called Native Plugins, and this tutorial will teach you how to build them.

Source codes:

Continue reading

How to integrate Arduino with Unity

In this tutorial you will learn how Unity and Arduino can communicate using the serial port. This tutorial requires both C# and Arduino scripts; the labels  Unity  and  Arduino  will be used to avoid confusion.

The topic of connecting Arduino to Unity is further expanded in Asynchronous Serial Communication, where you can also download the entire Unity package.

Continue reading