In case you haven't yet had the pleasure, Unity3D is a modern 3D game engine akin to the Unreal engine or the Quake engine, designed as a platform to create 3D games for web, console, phone, and gas pump for all I know. We've been using Unity to design some of the games we make at work and so I've been learning the ins and outs of the API. Unity is a fantastic engine with lots of built in features, but one thing that somehow hasn't made it into the engine just yet is a system for ladders. You know ladders right? Those tall steppy things that get you up there from down here. Everyone loves ladders!
Well we needed some ladders for a project but good implementations seem to be few and far between, so I decided to make one myself and write up how to use it. Here's a little excerpt from the docs:
In the game these ladders function as follows:
- When the player comes into proximity of the ladder they will latch on. Once latched forward motion of the player is converted into vertical motion along the ladder.
- At the extreme bottom or top of the ladder the player can move away from the ladder using the normal controls, or along the ladder.
- While on the ladder, the player can only move side to side or up and down the ladder.
- While on the ladder, if the player looks down below a threshold value, then forward movement will climb down instead of up the ladder.
- While on the ladder, the player can press the jump key to jump off of the ladder.
- When the player exits the ladder at the top or bottom they will perform a very small hop.
- Ladders can be at any angle, however under normal settings the player can walk over objects at inclines under 45º, so in these cases a ladder may not be necessary.
- Ladders can be any size and shape from wide ladders to narrow vines.
And here's a little sample of what the setup looks like:
note: since I wrote this script Unity has been updated to version 3. I haven't tested the scripts on Unity3 just yet, but I think they should work just fine.
note note: Hello from the future. It's 2014 and Unity now at version 4.3 (wow!). I'm afraid I haven't been keeping up to speed with Unity as of late, but from the questions I get from time to time it sounds like this script may need some minor to in-depth tweaking to get it to run within the current system. I will continue to make the code available, but I'm afraid I can't offer any advice on how to get it running. Sorry. If anyone out would like to offer their services or an updated version, I invite you to leave your links and details in the comments below.