Rehashing Some Basics

It’s been a while since I wrote some C++. I’m going to spend a couple of days messing around in UE4 on a FPS starter template to refresh my skills.

Today I booted up the template and checked out what the default gives me. Basic directional movement, a jump, a single fire weapon and some weird ping-pong ball projectiles.

I’ve been playing a lot of the new DOOM recently so first things first I’m going to add a double jump to this thing.

Simple job, the MyProjectCharacter class inherits from Character, Character has a couple of jump related functions for the basic behavior. I can keep using the function that actually moves the character object in a jumping pattern, all I need to do is overwrite two functions, CanJumpInternal_Implementation, OnJumped(), and OnLanded(). I’m going to increment a count of how many times the player has jumped in one go, check it against a max limit of jump they’re allowed to do, and reset that counter when they land on the ground.

CanJumpInternal_Implementation is weirdly named due to something related to blueprints, anyway this function is just going to check if CurrentJumpCount < MaxJumpCount, allow the player to jump, otherwise don’t allow the jump. OnJumped() will increment that count, OnLanded() will set the count to 0. OnJumped() and OnLanded() are events exposed by the Character parent class so I just need to override their definition and do that behavior and we’re good to go.

Easy, quick, next I’m going to amp up that weapon a little bit.

Leave a comment