Movement Updates
MedievalCombatProject
The Character’s movement has been updated with strafing depending on the Player’s keyboard input.
In comparison, in the earlier versions, the Character would rotate in the direction of the keyboard input (done by
setting GetCharacterMovement()->bOrientRotationToMovement
to true
).
Setting up Animations
I downloaded six additional animations from Mixamo for each PlayerState: Strafe Walk & Run - Left, Right and Back. (I already had the Forward Animations.)
Additionally, I added 4 Animations for Diagonal jogging in case the Player holds down one of the Forward and Right movement buttons simultaneously.
After setting up, the Animations were put in a 2D BlendSpace (as opposed to the 1D BlendSpace used before) like so:
The Axes in the BlendSpace are SpeedForward (Y Axis) and SpeedRight (X Axis). These two values determine which Movement Animation has to be played.
As the value of SpeedForward increases from -375
to 375
, the Backward animations blend to the Forward animations. Similarly, as SpeedRight
increases, the Left animations blend to Right.
SpeedForward and SpeedRight are calculated as follows:
FVector Speed = Pawn->GetVelocity();
SpeedForward = FVector::DotProduct(Pawn->GetActorForwardVector(), Speed);
SpeedRight = FVector::DotProduct(Pawn->GetActorRightVector(), Speed);
These two values are passed in the Animation Blueprint instead of MovementSpeed
.
So as a result, the Character can strafe depending on the input instead of always rotating in the direction of input.
Other changes
- Added a new map “SpringLandscape”
- Changed the original camera position to be closer to the Character (Like the recent God Of War game).
- Made the camera smoothly zoom in and out when the Character enters and leaves Combat Mode.
- Added a crosshair that appears when the Character goes into Combat Mode.
You can view the code of the project here!
The Result!
- Unarmed
- One-Handed Armed
- Two-Handed Armed