Progress Report: Wrapping Up the 2.5D Platformer Prototype
Today, I’m wrapping up the last little features in my Unity 2.5D platformer and preparing to transition them to a more fully realized level.
Cinemachine Camera Follow
It’s hard to believe I did most of this work without a follow cam. Oh, well, time to get it in there now.
I’ll start by adding a Cinemachine Brain component to my main camera and creating a new Cinemachine virtual camera. There’s a handy little spot in the virtual camera to drag the player, labeled “Follow.”
That’s all we need. I set the y-rotation to -90 to get a side view. Now, the camera will stick to us. Using the Framing Transposer body will give a little natural motion to the camera as it follows. Looks nice.
We have two more animations to add to our already packed animator: jumping in place, and rolling.
Jumping in place is super simple. If our speed is zero when the jump key is pressed we trigger a different animation for jumping. No problem.
Rolling requires a little bit more thought. I need a new input key, and I also need to change the size of the character’s collider before and after the animation. For this we’ll need another animation behavior script.
For the input, I’ll use the following:
if the left shift is pressed && controller velocity is not zero
… set the animator’s “Roll” trigger
…controller height = 1.25
…controller center y = .62
The center of the collider also needs to change, so the character doesn’t dip into the ground as the animations transition back to standing/running.
I’ll add an animation behavior script (not shown) that refers to the Player’s RollComplete() method (below). It resets the controller size to its original values (which I stored in variables in the Start() method).
I’ve downloaded my environment package, and adapted it to include my mechanics. Let’s see how it looks.
Hey, look at that — everything works.
Tomorrow I’ll talk about my progress so far in the 60 days since I started this blog.