Stuck in a Loop


The Problem:

One problem I had this week, more like a nuisance, was our jump animation for the player was not split up into a jump start, jump loop, and jump end animations. The problem with this is that if the player jumped off a high enough edge, the animation would loop back to the beginning which looked pretty bad and the jumping sound effects would also loop.

However, a much more important problem we had in my opinion is that while attacking, the player has no control over their character. For example, if they continuously pressed the attack button, the attack animations would move the character forward with each attack and any sort of directional input from the player would be ignored. When playing most games like this, if not all, I expect applying any directional input when attacking causes the direction of my attack to change and correlate with my input. So, that's what I worked on implementing this week.


The Solution: As my soccer coach once told me, "Turn your shoulders!"

First, to fix the problem with the looping jump animation I just had to go out and find a looping falling animation and just cut up the current jumping animation so that I have separate start and end animations. With the three separate animations now in hand, all I had to do was apply the proper transition conditions and we have a more realistic looking and feeling jump.

To allow the player to turn to their direction of input, I grabbed the direction, which is based on the yaw rotation of the controller input, that the player would move in. I took the dot product of the Actor's right vector and that direction and rotated the Actor based on the result of the dot product.

FVector rightVector = GetActorRightVector(); 
float dotResult = Dot3(Direction, rightVector); 
FRotator newRot(0.0f, dotResult * 2.0f, 0.0f); AddActorWorldRotation(newRot.Quaternion());

I was initially having trouble with this because I was using the Actor's forward instead of its right but once I realized that mistake I got it properly.

Get Lucifer's Hordes

Leave a comment

Log in with itch.io to leave a comment.