Any ideas how to handle combat?

Let’s say I have two humanoid models. There are attack and defense animations on the models.

For example, when I click the mouse, the player character starts an attack animation. What is the best way to detect if an enemy has been hit, and at what point in time?

P:S. I just need a general understanding, I don’t need code examples.

This can be detailed or abstracted. Detailed would use hitboxes on the skeleton for instance and test for actual collision, force etc.

The more abstract way most games use is just testing if you’re close enough to the enemy, and a specific time of the attack animation reached to trigger the damage. For “close enough” basically simply a distance in which the strike approximately reaches the enemy. Some games even give a lot more tolerance where you’re not visually even hitting the enemy.

Additionally you should test if the direction of attack and direction towards enemy is within a angle of tolerance, for instance 30°, but a lot will depend on the type of attack or weapon that might not have a directional limit.

3 Likes

Very helpful, thank you!