Raycasting Part 1: Everybody Loves Raycasting

Raycasting is one of those topics that everyone seems to struggle with at first, so here is a tutorial covering everything you need to know about raycasting in Unity. In this post I’ll explain what a raycast is, how to use a simple raycast, and point out a few potential problems and pitfalls people run … Read moreRaycasting Part 1: Everybody Loves Raycasting

Save Time and Hassle with RequireComponent

You can use RequireComponent in your Unity scripts to save yourself some work and avoid errors. When your script requires a component, Unity will add a component of that type to your GameObject automatically when you add your script (if a component of the required type is not already there). You also cannot remove this … Read moreSave Time and Hassle with RequireComponent

A Navigation Helper for Unity

Unity lacks a way to pass parameters to a new scene. If you want to send some game state data to the next level you have several options, such as PlayerPrefs or persistent classes, but they are not always elegant solutions. I decided to copy NavigationHelper from Windows Store apps. NavigationHelper allows you to send an object when navigating to a new … Read moreA Navigation Helper for Unity

Giving Enemies the Power of Sight!

Enemies are more challenging when they have some intelligence. A great start to building enemy AI is to grant enemies the power of sight! Sight is really a test that there is clear space between the enemy’s eyes and the player. With that knowledge it’s simple to work out a solution. You can download the sample project at the bottom of … Read moreGiving Enemies the Power of Sight!

Change a Sprite’s Transparency

Adjusting a sprite’s transparency can add dynamic ‘juice’ to your game. You can make items flash on and off, make translucent ghost, or fade away your UI buttons. It happens to be really easy to achieve via Unity’s SpriteRenderer component. Change a Sprite’s Transparency You can’t change the alpha value directly, so instead you need … Read moreChange a Sprite’s Transparency