Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Fat Pug Studio on April 11, 2018, 08:26:12 AM

Title: Logic help on splash damage
Post by: Fat Pug Studio on April 11, 2018, 08:26:12 AM
Hi guys,

i want to make some explosions have radius based damage that can damage multiple enemies, but my current bullet/enemy/damage setup is giving me a hard time.

At the moment, all the damage dealing stuff is set up like this:


It can be simpler, but i have many modifications that makes it necessary to work this way.

Splash damage is easy to implement from the enemy side, as every enemy can detect the collision with the explosion collider and apply damage to itself, but since the logic of dealing damage in my case is on the bullet/explosion side, only the first enemy that collides with the explosion will be hit, and rest will remain undamaged.

Any ideas on this one? Some spherecast with adding enemies in the blast radius to an array and the cycling through all of them?
Title: Re: Logic help on splash damage
Post by: CookiMonster on April 11, 2018, 09:41:12 AM
It would be easy to do it with array. After the trigger hits use the "array add" and to send the deal dmg event use the "array get next" action. This have to happen within one frame to all enemys inside the trigger.
Title: Re: Logic help on splash damage
Post by: Fat Pug Studio on April 11, 2018, 09:50:11 AM
Yeah, but won't the collider on the explosion trigger with only one enemy?
Title: Re: Logic help on splash damage
Post by: Fat Pug Studio on April 11, 2018, 10:41:29 AM
A-ha, i should cast overlap sphere, i'll check that out.
Title: Re: Logic help on splash damage
Post by: CookiMonster on April 11, 2018, 03:04:41 PM
Nope u can collide/trigger with 1000 object by default within a frame.
Title: Re: Logic help on splash damage
Post by: Fat Pug Studio on April 11, 2018, 03:06:52 PM
I can't get it working with neither ArrayListFindGameObjectsInsideCollider2D nor ArrayListCastOverlapSphere, any ideas on properly setting these up?
Title: Re: Logic help on splash damage
Post by: Fat Pug Studio on April 11, 2018, 03:13:03 PM
Nope u can collide/trigger with 1000 object by default within a frame.

Yeah, but how to loop through all of them and don't repeat what's been hit? I tried with get trigger info and the object hit and then add to arraylist, but they all have the same name, so only one is added.
Title: Re: Logic help on splash damage
Post by: Fat Pug Studio on April 11, 2018, 03:25:08 PM
ArrayListFindGameObjectsInsideCollider2D needs to have mesh renderer on itself, trying out the List Game Objects Inside Collider 2D.