Post feature RSS About character locomotion

A small discussion about locomotion considerations when you choose to have a third person style game.

Posted by on

Regardless of the genre (action/adventure), Parasite is technically a third person shooter that lets you jump (third person shooters like Dead Space and others don't include jumping mechanics). The Subject can walk, run, jump and shoot (on a technical level, it can't get any simpler than that, although the entire character mechanics+locomotions are 1315 lines of code), but a few different situations had to be considered.

Parasite uses the standard "always behind you" in favor of the free camera used in Tomb Raider or Batman Arkham Asylum, meaning The Subject is able to move forward, backwards, and also strafe left and right (free style cameras make the character always "run forward" regardless of the direction of movement, as you know).

Walks and runs aren't really affected much by this, since all she does is obey the player input to move in the specified direction, but jumpings are a different scenario. So not only I had to tell the system when the character is moving or not moving, so she performs a specific animation when she's in idle, and a different one when she's moving, but also tell the system the direction she's moving in, so she jumps diferently. The video shows the whole locomotion system in action (and you also get to see how The Subject looks like in a not-so-cool empty environment included with UDK that makes her look like a ghost, heh. I just figured it was better than using an all-white-and-blue chess square room).

So this is the part where we get a little more technical... Knowing if she's moving or not is as easy as using the "IsZero" function inside the character Tick:

event Tick( float DeltaTime )
 //`Log("character not moving");

The IsZero(Velocity) is true as long as she's not moving. The key here is "not moving" because the function will return false if the character is inside PHYS_Falling (because she's actually moving downwards) or PHYS_Swimming (because the fluid friction and buoyancy and all makes her move up, down, or to the sides).

The next step is to use this inside the jump function [ function bool DoJump( bool bUpdating ) ]so she performs a different type of jump depending on the IsZero(Velocity) condition. The entire custom DoJump function is way too long and depends on other functions so I'm not posting it here (the custom jump functions alone are 183 lines of code). You can, however, take a look at the DoJump function inside the base Pawn class and figure the rest by yourself.

Now the fun part... if she's moving forward, she should jump one way, but if she's moving to the left, the performed jump should be different. In this case I totally cheated and created a function that sets a flag based on the direction she's moving, which is actually connected to the pressed input. For example, you press forward...

function SetMovingForward()
 `Log("is moving forward");

That MovingForward=true flag is checked inside the DoJump function, and tells the system to execute the forward jump. Same goes for any other direction. The really fun part is when she's moving, for example, forward and to the left instead of just forward or just to the left. In this case you either need to setup a specific jump for this, or execute any of the available directional jumps, and tell the system which direction takes priority (in my case I chose the second option, and I set it up so that forward-backwards always have higher priority over left and right).

Half of this is only needed because of the third-person-shooter camera. If you use a free camera, you only need the IsZero(Velocity) to check if your character is moving or not, because if !IsZero(Velocity) your character will always be moving "forward."

Well that's all for today, I hope you find the info here useful, or at least interesting :)

*The jumping mechanic alone adds a bunch more stuff into the "what-if" black box. It adds a lot more places where the character "can go," like getting onto a crate (something that never happens in Dead Space, for example, because white men like Isaac can't jump), and also the complexity of how the player should use jumps in a way they make sense, level-wise, while preventing them from jumping off a bridge to a certain horrible death just because they decided to jump where they actually couldn't...

See you next time!

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.