Catching and Parrying mechanics

By Chris Caruthers

My task for a while was to create catching, blocking, and parrying mechanics for the player, which could later be repurposed for the AI enemies to use. I started with catching/blocking at it was much simpler. I figured I could just use a simple timer linked with a button press to allow for catching within a certain time frame. This worked pretty well, and as the ball collided with the player, if the bool was flipped the player would gain a ball to throw and remove it from the playing field. As a basic exploit prevention I added an additional timer that continued past the catching time window, which disallows the player from attempting another catch for another 0.15 seconds. This worked really well, so I figured I could essentially reuse this for parrying, which I did with more difficult timings. The difference with parrying is that it had to affect the ball itself, so the ball had to have a function that would allow it to set a target and a speed for the player to pass to it when they parried. The ball receives these, flips its ownership, and begins tracking. The tracking I implemented on the ball was actually quite similar to the steering behaviors I gave the enemies. It adjusts its current velocity every frame by the difference between its velocity vector and the vector from it to the target. With some initial tweaking this causes the ball to take a nice path towards the enemy without homing too strongly, but still consistent enough for it to be worth parrying shots.

Comments

Popular Posts