vrijdag 30 januari 2015

Firing 2D Projectiles in Unity3D with C#

If you have ever tried to make a 2D projectile in Unity, you may have encountered a problem. You want the projectile to face its target, right? Well, that isn't as simple as it would seem, as there isn't a look-at function for 2D game objects. Not yet at least, I've come across posts claiming the developers at Unity were working to implement that function.

But I don't want to wait, that's why I made one myself.

donderdag 29 januari 2015

Screen-shake in Unity3D with C#

Ever felt like a game was missing something? Just a little bit more feedback or a cool effect? Or you just wanted to be more like Vlambeer. Screen-shake can be the thing you're looking for.

In my opinion, if screen-shake is used correctly it can instantly make the game feel a lot more polished and "done", even if it's just an early prototype. Same goes for music and sound-effects, but today I'm writing about screen-shake.

woensdag 28 januari 2015

Simple Patrolling 2D AI in Unity3D with C#

Ever wanted to have a simple AI character in a 2D platforming game that you could easily assign patrol routes to? Well that's a pretty specific request, but have I got the thing for you!

What this script does, is move the AI game object from marker to marker, which can be any transform component. I prefer to use empty game objects with icons on them so I can see and select them in the editor, but you can't see them in-game. Of course you can use this marker system to your advantage. For example, if you want the player to be able to see the path the AI takes in a stealth game. Or you can make it so that the markers disappear when the AI reaches them and make the player able to create new markers, voila, strategy game!

You can also imagine using this script in combination with the microphone input in my previous post. A stealth game where you can shout into the microphone to distract the guards, or maybe whisper to prevent them from hearing you pass important information.

maandag 26 januari 2015

Microphone Input in Unity3D with C#

I once thought to myself: "You know what would really be cool? If I could use the player's microphone input in my games!" So I did some research.

I've found, and experimented with this, which is just a simple piece of code which can be slapped onto any Unity3D game, pro or no, and it just works. If it's made in version 3.5 or higher.
But since you're reading this now, and at the time of creation Unity3D version 5 is nearing its release, I'm just gonna assume that you're using a more advanced version than 3.5.

Let me show you: