New Player Movement


This post was written back in July, but was mistakenly not published until December 2019.

I was never really happy with the player movement in Ascension III. I wrote the original code years ago, probably for another project. I did rework it about a year ago to add sprinting, crouch, and jumping, but it was very hacky and never worked well. My skills have improved since then and with the shift in focus to combat, movement has become much more critical.

I'm going for a classic FPS feel for the player movement in Ascension III. Doom, Quake, Duke Nukem 3D and the original Half-Life are all major inspirations. That includes the "flaws"- we'll have straferunning, rapid jumping, and possibly bunnyhopping as well. There won't be any explicit dodging mechanics in Ascension III, so the movement has to be good. I was frustrated trying to dodge dragon attacks in Skyrim a few days ago, and I'm pretty dead-set on having much tighter movement mechanics in my own game. Fast and fluid is the order of the day.


The new movement code is physically-based... ish. The basic idea is that the player has a velocity value that is applied every frame or tick, and is manipulated by control inputs or external forces. Acceleration, instantaneous velocity change, or instantaneous displacement can be applied to the player. A CharacterController is still used for collision detection, and there is some slightly weird stuff going on to keep the player from flying off the ground and to handle slopes.

I kind of regret going with that model. It seemed to make a lot of sense to me at the time, and it has the advantage of being able to apply external forces (say, from a conveyor belt or explosion) very easily. However, I ended up having to set several parameters to truly unrealistic values to approximate a the feel I was going for.


Right now we have walking, running, crouching, sprinting, jumping, air movement, gravity and slope sliding working. Slope sliding is buggy, and crouching works but lacks animations, sounds, or indicators so it's hard to tell when you're crouched. Sounds don't really work properly- that code was copied from the old implementation- and animations flat-out aren't in yet.

There's also a noclip/fly mode for debugging, which was really quick to implement but a fun little diversion nonetheless. It should also persist across scenes now, which it didn't do before because of the way it was implemented. I also added collision handling to the player movement controller, which is based on momentum transfer. The player has a mass and transfer factor, the other object has a mass. We calculate our momentum, trade some off, and scale our own velocity. I don't think it's entirely physically correct but it seems to work decently well.

The code is kind of dirty and first-draft-ish, and I haven't published the source yet (though I will). It definitely requires tweaking, as well as implementation of a few missing features, but since I'm trying to make the demo for an event in the fall, I'm very much in the "get it good enough" mode, and it's already a lot better. We'll come back later to add the missing features and fix the issues later, when the time pressure isn't so bad.

Next up is weapons handling, which is a pretty major rework.

Get Ascension III

Leave a comment

Log in with itch.io to leave a comment.