Project Overview
This project was for experience GitHub i was playing a game called deepwoken and their way of combat inspired me to try and make my own.
Concept & Planning
I looked at parry mechanics from different games (Deepwoken, Dark Souls games & Tekken) and then broke them down each based on how they work. Then made a small area where i can test how it works.
Parry Mechanic Breakdown
For example in darksouls you have to press block at a specific set of frames to get the parry off. In deepwoken when you press block, a sphereGizmo is cast around you and if there are players within that radius that attacked you within your parry animation, you parry them. I decided for practice i should start with the deepwoken parry mechanic first since it seems the easiest.
Deepwoken parry Mechanic
My replica
Development
After i checked the mechanic I wanted the code to remain efficient yet simple, so I could implement it easily into the animation sequence. On GetKeyDown F I cast a sphereCastAll that checks the position of the objects inside of its radius, then for each RayCast it hits, it checks if the collider has the Tag enemy. If the object has the tag enemy and then enemy script gives the signal it can be parried, then the parry will be invoked through the animation.
The code
In editor look
Animator Sequence
I tried to replicate that feature using scripts only first but after playing around it became clear that it is alot harder to do it via script only, so i went back to studying the mechanic. I noticed from breaking down the mechanics from Deepwoken that there is a certain point in the animation which triggers an can parry function. After figuring out how to trigger the function the rest went pretty smooth.
Animation Frames
The animator
Final Result
The final result of the mechanic.
Parry and block Mechanic
Technical Challenges
The biggest issue i had was linking the animations from the sequence to the script and making them work/react to the interactions between player/enemy. It was a difficult but really good learning experience.