I am creating a third person survival game for mobile and I am able to move my character with joystick, press button to run attack animation. The problem is how the object know it being hit.
There are a million different ways to do this but two easy ways are:
- Whenever you play the animation, just check if there is anything in front of you (check out Physics.OverlapSphere, you can cast a sphere right in front of you when you attack and see if anything is there)
- If you want more precise control over hit boxes for your weapon, you could attach invisible colliders as children to your weapon, so that they move with the animation. Then you can look at their OnCollisionEnter function to see when they hit something