Project Alex - MovementStates (GaitProfiles) - Resident Evil 4 & The Callisto Protocol inspired Locomotion & Combat system


Hi - this post is all about movement and gaits. There are different types of gaits in games - walking, jogging, crouching, swimming and jumping can be also defined as gaits of sort. We can treat them as sets of properties that change in each gait. In this post I will show you how i made small system that changes the gait of my character in response to player inputs. The system is designed to have synergy with camera system but is completely independent, the only meeting point are the same gameplay tags the player gets applied through inputs.

There are a few rules that i want to keep in mind:

  • Profiles utilize gameplay tags,
  • Only one profile can be active at a time,
  • Profiles can be overriden by external factors ex. going through the deep water would force certain profile that the player would not be able to change by inputs,
  • Profiles do not change instantly but wait for conditions to meet.

Final effect - player can change its movement profile and camera modifier independently applying gameplay tags:


Idea and flow:

  1. Gait profiles are created and added to the DefaultGaitList in ExtendedCharacter MovementComponent
  2. When game is played tags are added to AbilitySystemComponent through GameplayEffects or AddLooseGameplayTags.
  3. Extended Character Movement checks these tags periodically using AbilitySystemInterface and if GaitProfile's all Required tags match it and IgnoredTags are not present it gets queued.
  4. Queue waits until current gait max speed is reached then does SetGait() which sets new values to character movement properties defined in FAlexGaitProfileInfo
  5. There is also a separate OverrideGaitProfile which can be set and cleared using SetOverrideGait() and ClearOverrideGait(), if present override the default list of gaits.

When should the profile actually switch?

Between changing GaitProfiles there will be a short period of changing from 150 to 300 using acceleration or deceleration. This change should make the player feel heavier.

To fully use the acceleration and deceleration values the best time to switch profile previous one is fully blended in. This way we get realistic acceleration and deceleration which creates that weighty movement. When character reaches given profile max speed it means the state is fully blended.

I utilize gameplay effects instead of adding loose gameplay tags to keep functionality of disabling gameplay tags when their parent effects are still applied, the effect is there but the tag is not present. I use them to cancel out mutually exclusive tags that are happening at the same time.

Input.Movement.Walk gets disabled if Input.Movement.Jog is present.

Flow of events currently used in when using movement inputs:

  1. Player presses input related to movement (WSAD)
  2. Gameplay effect (GE_Walk) is applied
  3. GE_Walk adds Input.Movement.Walk to the player's ASC
  4. Character movement responds to this tag and queues BP_WalkProfile
  5. BP_WalkProfile gets applied, but only if the player actually moves and it's speed matches the one defined in BP_WalkProfile. If the player does not move tags are not applied.
  6. BP_WalkProfile Adds Loose Gameplay tag Event.Movement.Walk which then can be used in camera profiles to modify its behavior.
  7. Player presses input related to jog (Left Shift)
  8. Gameplay effect (GE_Jog) is applied, but GE_Walk is setup in a way that it gets canceled when Movement.Input.Jog is present effectively removing Movement.Input.Walk so both are not present at once.
  9. The same happens as in point 4 but for BP_JogProfile.

The idea is to separate input tags from gait tags. Input tags can be applied but gameplay effects and character movement will use them at their own time giving us structure to work with. I can use camera system with gait profiles, applying a gameplay tag during different gaits lets me create different camera movements for example: camera can be close to the character when walking, or far when jogging. All of this happens with a bit of delay due to nature of queueing gait profiles.


For this system i made a few new classes:

FAlexGaitProfileInfo

AlexGaitProfile

ExtendedCharacterMovementComponent

FAlexGaitProfileInfo:

AlexGaitProfile:


ExtendedCharacterMovementComponent:

Component Initializes a list of instances at the start of the game and checks periodically for changes in tags during UpdateGait();


SelectGait() Looks for the best GaitProfile based on RequiredTags and IgnoredTags, then queues it


QueueGait() Waits for the character to reach the desired treshold speed then does SetGait()


SetGait() Sets new movement related values and adds tags which can later by used by the camera system.

RecalculateSpeedForDirection() changes max speed if character moves backwards - it's hard to move at fullspeed when you cant see :D

As for overriding Gaits updating gait is blocked by simple check in CanUpdateGaitProfile() - If its there nothing can override it.


You can see it again in  final effect whe the character walks through barely visible trigger box - sorry :D

That's it :D Hope you learned something - I certainly did, I made these changes happen mostly during Tick event, even though I implemented a cooldown  it might not always be the best idea, but for the systems that change often  - in this case movement and camera change all the time when you play, it is worth the cost. I might optimize it in the future. who knows, thanks for reading :D ! If you have any feedback about the posts, maybe their format, language, screenshot or whatever, let me know :)

Leave a comment

Log in with itch.io to leave a comment.