Archive for the ‘Programming’ Category

Unity: Slow Motion and Rigidbody behavior

Click here to read Unity: Slow Motion and Rigidbody behavior

It’s been awhile since the last Unity post, in fact, it’s been quite some time since there’s something new on the website. I want apologize to all the 41 Post readers for taking so long to put together a new tutorial. So, let’s get to the tutorial.

This post explains how to set the parameters found at Unity’s Time class to make the game run in slow motion (also known as “bullet time”). It’s important to note that the following code was created for Unity3D 3.4, thus, the code featured below might work different in other Unity versions. Continue reading: “Unity: Slow Motion and Rigidbody behavior”

Android: Disabling anti-aliasing for pixel art

Click here to read Android: Disabling anti-aliasing for pixel art

Android is great when it comes to displaying scaled pictures in applications and games since it tries to interpolate the pixels, making the resulting image look as good as possible. That works for almost every case, however, what about pixel art? This behavior isn’t good for that because, after scaling it, the resulting image will be “smoothed out”, invalidating the handcrafted pixel placement.

There are two options in this case: use an image with the correct size and never scale it, or try to disable anything that could be aliasing the image. This post is going to describe how to do the latter. As usual, an example project is available for download at the end of the post. Continue reading: “Android: Disabling anti-aliasing for pixel art”

Android: Transparent or Translucent View Background

Click here to read Android: Transparent or Translucent View Background

This Android post is going to explain how to change the background color of a View, to make it completely or partially transparent. It may seen a little strange at first, but sometimes it makes sense to create a translucent or transparent background, like when coding an application with multiple viewports, such as a graphic editing tool, for example. Luckily, Android has already some built-in features that aids the programmer in achieving total or partial transparency at any required level.

So, to create a fully transparent background, all that’s needed is to add the following line to the Manifest file: Continue reading: “Android: Transparent or Translucent View Background”

Android: Detecting Double Tap Events

Click here to read Android: Detecting Double Tap Events

This Android tutorial explains how to create an Activity that “listens” to double tap events. Doing that isn’t as trivial as getting a single tap from the screen, however writing a code that registers when the screen has been touched twice isn’t complex either. The example featured in this post works on the emulator and on a real Android device.

To implement the double tap, some classes and interfaces are going to be needed, but it’s best to show the example Activity code before explaining each one of them: Continue reading: “Android: Detecting Double Tap Events”

Unity: Raycast Reflection

Click here to read Unity: Raycast Reflection

As any person that has already used Unity’s Ray class knows, there’s no support for reflection, which could be useful for some specific cases. This post will try to offer a solution to that, explaining how to create a script which casts a ray that gets reflected when it hits a surface. Not only that, but the script also allows to set the number of times the cast ray should bounce. An example project with a scene and the code explained below is available for download at the end of the tutorial.

Before looking how the reflection script works, a scene must be set with some walls to reflect the ray. Additionally, a game object will be required to act as the source of the ray . To create the ray’s source, just select GameObject->Create Other->Cube: Continue reading: “Unity: Raycast Reflection”