playMaker

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

hoyoyo80

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
How to achieve AOE attack?
« on: April 03, 2019, 09:40:19 PM »
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

  • Junior Playmaker
  • **
  • Posts: 71
    • View Profile
Re: How to achieve AOE attack?
« Reply #1 on: April 03, 2019, 11:30:18 PM »
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

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: How to achieve AOE attack?
« Reply #2 on: April 04, 2019, 12: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: 699
    • View Profile
Re: How to achieve AOE attack?
« Reply #3 on: April 04, 2019, 02: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

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: How to achieve AOE attack?
« Reply #4 on: April 04, 2019, 08: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:)