Hi everybody, I’m doing an action game with a character that uses a sword. I made some particle effects that are created when the character hits an enemy. I want to know how can I instantiate that particle at the point when the sword hits the enemy.
On the image, the red rectangle is the collider from the sword, and the blue is the enemy. The collision is made with the OnTriggerEnter method.
I already made the particle instantiate on hit, but it was made at the position of the enemy, and it looked weird. The same with the sword.
For the exact position, you are going to have to abandon generic capsules and go for body part colliders. These would denote the placement of any given body part. Then, on the sword, I would put a (or a couple) of points. Every turn, you run a Raycast from the last point where the sword was, and the current point, and if that point hits another target, then you initiate the blood point there. Each update, you then add more blood splats until you reach about 0.25 seconds after the initial hit. Then the blood stops.
Using several points means that you get more blood the deeper it goes. You may also use this as a hit spot generator. So you could decapitate someone based on the blade.