Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: hoyoyo80 on April 04, 2019, 12:40:19 AM
-
Hi all,
Im trying to implement an AOE attack with weapon for multiple enemies.
My setup:
1.Set a Box shape trigger parent to player and place in front of player.
2.When player attack, trigger action will detect any enemy within the box trigger.
3.Send event to enemy to deduct their health.
With this setup, i successfully hit the enemy but only one of them. ive learned that the trigger will trigger one object once.How to detect multiple enemies then?
Thanks
-
Or you could try to use this
1. Set a box (I call it Hitbox) put trigger and animation of slash or something
2. Prefab it and name it Hitbox/Slashbox or whatever and give a tag "Hitbox"
3. whenever a player swing a sword, spawn the hitbox (don't forget to despawn self/destroy self on the hitbox, so it will destroy itself)
on the enemy side,
onTrigger with object tag "Hitbox" = Damages
Good luck
-
Thanks for the reply.
I have no problem hitting One Enemy, but how about detecting multiple of enemies at that current attack?
Thanks
-
Keep an array of enemies.
1. Keep an array of active enemy gameobject.
2. Fire weapon. Get the hit position.
3. Loop through array of all enemy who are within distance of hit position.
4. Check line of sight (if necessary) for each one using linecast as well (if you need to check they are behind walls and such).
5. Send damage to all who are both within distance and line of sight.
Or, use a box cast. Get an array of all enemy within the box (use a tag compare). Then send an event to everyone in that array. After finishing, empty the array for next time.
-
The array suggestion really help to sort out the problem.
Now my setup is:
1.Using List Object Insider Collider(ArrayMaker/List)
2.Iterate the list, process and remove
Now, AOE work.Thanks:)