I've only been using Unity for a very short time and got stuck at one point. I explain.
It is a 2D platform game. I want that when hitting an enemy with a sword, right at the point where the collision has taken place, place a particle effect, but since I have never done it, I have many doubts. In the player I am using Physics2D.OverlapCircleAll which detects the collision with the enemy and inflicts damage, but I also want to place a contact effect (animation of contact with the particle system) right at that point of collision, although I wouldn't even know where or how to put it.
This is the method that registers the collision with an enemy:
void Hit()
{
Collider2D[] collided_objects = Physics2D.OverlapCircleAll(attack_controller.position, attack_radius, is_an_enemy);
foreach (Collider2D collider in collided_objects)
{
collider.transform.GetComponent<Enemy>().enemy_damage(attack_damage, attack_power);
}
slash_weak_effect.Play();
}
But the problem is that the effect always appears in the same place and it looks very ugly. My null knowledge does not manage to reach further. I have investigated on the net and I have not found anything, that's why I turn to you.
Where and how can I place this effect to make it realistic? In other words, I need something that places the particles at the exact point where the character's sword touches the enemy's collider.
Sorry if the question may be stupid for experts