Archive for the ‘Programming’ Category

Unity: Normal Walker

Click here to read Unity: Normal Walker

This Unity programming tutorial explains how to create a controllable character that appears to ‘walk’ on the surface of another object. That’s achieved by using a script that matches the normal up orientation vector of the controllable game object with the surface normal of the other 3D object. But not only the script, this post also explains how to set up a scene to make it work.

A demo project with everything discussed here is available at the end of the post both in C# and JavaScript.

The first step is to create a Cube game object, that will act as your player. To do it, just select GameObject->Create Other->New Cube: Continue reading: “Unity: Normal Walker”

Unity: Rotation Controller

Click here to read Unity: Rotation Controller

Another day, another Unity3D programming post. This tutorial contains not just one, but two scripts that rotates a game object around another one, based on the keyboard input. Again, like the previous tutorial, this was also inspired by retro games, such as S.T.U.N. Runner or the special stages from Sonic 2, where the player controls the main character by pressing left or right, making it complete a full circle in the screen. However, unlike those games, the below scripts aren’t applying gravity to the player, for the sake of simplicity. Everything explained here is available for download at the end of the tutorial.

Continue reading: “Unity: Rotation Controller”

Unity: Throttle Controller

Click here to read Unity: Throttle Controller

This Unity programming tutorial will explain how to create a script that translates the containing game object forward at a pre-defined speed rate. This rate is controlled by a throttle much like the ones found in boats, planes or even trains. As usual, a Unity project with a working demonstration of this code is available at the end of the post.

The inspiration behind this tutorial came from the first Half-Life game, in which a train at the end of the tutorial level can have its velocity is gradually set by the player. Some of you may not remember how it looked like, so here’s a screenshot: Continue reading: “Unity: Throttle Controller”

Android: reading float values from a XML file

Click here to read Android: reading float values from a XML file

When programming an Android app, data such as integers, drawables and strings can be loaded from XML files through the Resources class, using their automatically generated IDs. But a float can’t be placed in these XML files, since the Resources class won’t generate IDs for it. This post will focus on explaining how to load a float, and some other values from a customized XML file. All code featured in this tutorial is available at the end of the post.

It’s worth mentioning that this example uses the XmlResourceParser class (a XML pull parser) to read the contents from a XML file. This is just one of the three available methods of retrieving the contents of a XML file in Android. That being said, the first thing we are going to need is the XML file. Continue reading: “Android: reading float values from a XML file”

Android: changing the ringer volume

Click here to read Android: changing the ringer volume

Another Android tutorial, this time, explaining how to change the different sound volumes of the Android system, such as the ringer, music and notification loudness. The source code featured below is available for download at the end of the post.

Using a seek bar to control audio’s volume in Android is a lot like changing the screen brightness with a seek bar. However, instead of using a ContentResolver to obtain the service that controls the audio, Android has a class that makes everything easier, named AudioManager. So, the example here will basically obtain a reference to the AudioManager and will use it to get the current ringer volume and use it to set the progress of a seek bar. When changed, the seek bar progress will set the value of the sound volume. Here is the code: Continue reading: “Android: changing the ringer volume”