So you want to add some stairs to your game? Great! Adding stairs in level design adds more vertical variety to your levels. Or perhaps your game is based on stairs (Stair Climbing Simulator 2018?).
In this tutorial I'll show you how to implement stair climbing from scratch in Unity3D if you're using a
Rigidbody as your player. Before we get to coding, you should consider your (much easier / less work) alternatives:
- Use a
CharacterController. It already has some support for this, but can't have physics applied willy nilly, nor is it as customizable as a
Rigidbodywith multiple colliders.
- Use a
Rigidbody. If you get the player going fast enough they can just ram right over the stairs.
- Use ramps or stairs with invisible ramps over the steps. They work just as well and even provide a smooth transition surface. Doesn't work for cases of dynamic/physics content or player generated content.