playMaker

Author Topic: How to achieve AOE attack?  (Read 1592 times)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
How to achieve AOE attack?
« 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

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: How to achieve AOE attack?
« Reply #1 on: April 04, 2019, 02:30:18 AM »
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

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: How to achieve AOE attack?
« Reply #2 on: April 04, 2019, 03:10:16 AM »
Thanks for the reply.


I have no problem hitting One Enemy, but how about detecting multiple of enemies at that current attack?

Thanks

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: How to achieve AOE attack?
« Reply #3 on: April 04, 2019, 05:15:20 AM »
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.

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: How to achieve AOE attack?
« Reply #4 on: April 04, 2019, 11:53:00 AM »
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:)