Lately I was learning how to use Blender to make 3D models (mostly because it’s polished and free). As a programmer, I wasn’t attempting to be a professional artists, but I did want to learn the basics in order to facilitate game development.
Blender is a pretty cool program if you learn the shortcuts and interface (I found a great tutorial here at “Games From Scratch”). However, if you want to use models made with Blender in Unity3D, the scale and orientation will be not be set in a way you would expect. This tutorial attempts to teach how to fix the scale and orientation of the Blender model so it shows up correctly in Unity.
Take note that this will be a manual orientation and scale fix. This doesn’t utilize scripts in either Unity or Blender. This tutorial assumes that you are at least a little familiar with navigating the interfaces of both programs (I consider myself a beginner in Blender, so hopefully Blender-beginners should be able to follow along). This tutorial uses Unity 4.5 and Blender 2.7.
Some several months ago, I made a much visited tutorial about rotating, panning, and zooming a camera in Unity3d. I was asked if it was possible to make the camera movement more smooth. While I thought the movement was already smooth, no one can ignore the fact that if you let go of mouse when moving the camera, it will suddenly stop.
A more desired behavior is for the camera to smoothly stop after letting go of the mouse. In order for this to work, the camera needs to have some inertia, thus physics properties.
In the link above with the revised camera script, I implemented a version of camera movement that will stop smoothly. You can even control this smoothness from the pubic variables
Internally, a RigidBody component would be required for this to work, but I made the script take care of that, so that you don’t have to. In other words, if you’re using this script on a camera, do NOT add a RigidBody component because the script will do that automatically.
You can get the GML script here. This post will explain the code.
When I was developing enemies in Yxi, I was trying to get turrets to aim at you, but I didn’t want them to possess “instant aim”. I wanted them to rotate towards you given a maximum rotation speed. If you move too fast, it should turn towards you gradually, not instantly.
It seems that it wasn’t as simple as I thought it was. I had the basic algorithm down, but because of the way Game Maker handled angles, the turrets would behave strangely when you would hover around the 0°/360° point with respect to the turret.
I figured a tutorial would be necessary for something that isn’t so obvious to implement. This only pertains to Game Maker and thus uses the GML language.
There are three steps involved when gradually rotating an object (let’s call it a turret for now) towards a target object:
- Calculate the target’s direction with respect to the turret’s position.
- Calculate the angle difference between the direction derived from step 1 (let’s call “target direction”) and the turret’s facing direction.
- Apply angular rotation towards the target so that the target direction is the facing direction.
[Update Jan 2017] Google stopped hosting links from Google Drive a while ago, so this post is basically useless now.
[UPDATE: Dec ’14] Hosting Unity games on Google Drive has recently stopped working (at least for me). Even when I follow Google’s new instructions for getting the hosting link, Unity games don’t load from Google Drive. This includes games that were previously hosted and used to work. So I’m afraid it is no longer possible to rely on Google Drive to host Unity games. Your mileage may vary.
[Update: Jan ’14] It seems Google thought it would be a good idea to change Google Drive’s interface a little bit. So I updated the tutorial to match the new interface.
In this tutorial, I’ll show you how to host a game made with Unity3D on Google Drive. This tutorial assumes you know what the Unity Web Player is. I have seen a few results on how to host a Unity web-game from Dropbox, but I personally couldn’t find one about hosting from Google Drive. I wanted to host a Unity3D game from Google Drive to present to the Ludum Dare game dev competition.
[This is a cross post from the Fortress Fiasco blog.]
While importing audio into the game, I came across an annoyance. Since Radioactive Lollipop weren’t using 3D sounds in Fortress Fiasco, I had to convert all audio to 2D sounds by unchecking “3D Sound” in the inspector. This is not too big of a deal with small sound effects, but with large music files, Unity ‘re-imports’ the audio file and can take a little while.
So if you’re making a game with Unity and for the most part your sounds will be 2D or you don’t want to waste time converting music to 2D, use this C# script. For it to work, you must name the script “Force2DSound” and put it in the Editor folder. If you don’t have an Editor folder, you’ll have to make one under the Assets folder (so it would be
"/Assets/Editor/Force2DSound.cs"). The script looks like this:
public class Force2DSound : AssetPostprocessor
public void OnPreprocessAudio()
AudioImporter ai = assetImporter as AudioImporter;
ai.threeD = false;
After making this script, just import some audio into the project. It should have “3D Sound” unchecked automatically. Enjoy.
[Update] It seems that if by chance you wanted a 3D sound and you checked “3D Sound” in the Inspector, it will enforce 2D sound. So now I only recommend you use this script if you only want 2D sounds. Delete this script once you want 3D sounds.
[Update 2] IMPORTANT: It seems this script doesn’t work properly in Unity 4.2. The imported sounds are labeled as not being 3D but when loaded into an AudioSource, it thinks they are 3D and plays them as 3D. I would NOT use this script anymore.
[Update 3] Changed
OnPreprocessAudio() and removed the AudioSource parameter. Works again, but you will still need to delete this script if you want 3D sounds in your game.
Link to code on bottom of post. ↓
In Caelium, one of the features I wanted was simple camera movement system that could rotate the camera, pan it on the plane defined by its forward direction, and zoom. In the video, I demonstrate the movement of a camera in Unity.
To rotate the camera, you left click the mouse and move around. To pan the camera, you right-click the mouse and move around. To zoom, you middle click the mouse and move up or down.
By no means is it perfect, but what I have now is pretty good, as you can see in the video. I’ll explain how the movements work.