playMaker

Author Topic: Help with TNT explosion and zombies  (Read 174 times)

InThAfAcE

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Help with TNT explosion and zombies
« on: February 27, 2021, 08:36:41 AM »
Hi. I have some TNT that i'm trying to kill some zombies with. I need a way find all zombies in a radius and store them in an event so i can set em to "dead" in puppetmaker which i'm using for my zombies. What action(s) should i use to find all visible zombies close to the TNT?

ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 111
    • View Profile
Re: Help with TNT explosion and zombies
« Reply #1 on: February 27, 2021, 10:14:22 AM »
One method would be to use Arraymaker:

1. Array List Find Objects By Tag (Zombie)

2. Array List Get Next (Zombie) - Get Distance (Zombie to TnT) - Float Compare (Distance vs BlastRadius)

3. If Distance <=(BlastRadius), Send Event "Death", else Loop back to Array List Get Next

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 5946
    • View Profile
    • jinxtergames
Re: Help with TNT explosion and zombies
« Reply #2 on: February 27, 2021, 02:32:41 PM »
Hi.
You can use 'Overlap Sphere' (Ecosystem)
It will place all the objects of your selected layers in an array.

Then you can loop thru the array by using 'Array Get Next'
and you can check the tag / name if needed.
Then you can do to that object what you want and loop back to the 'Array Get Next'

@ToxicFrog :
'Find' actions can become 'expensive' as it has go go thru all objects of you scene (including all child objects)
on bigger scenes you can get a short lag on it :)
« Last Edit: February 27, 2021, 02:35:50 PM by djaydino »

ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 111
    • View Profile
Re: Help with TNT explosion and zombies
« Reply #3 on: February 27, 2021, 02:47:25 PM »
Oooh I was not aware of Overlap Sphere!!! That promises to come in very handy

InThAfAcE

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with TNT explosion and zombies
« Reply #4 on: February 27, 2021, 05:07:37 PM »
Hi.
You can use 'Overlap Sphere' (Ecosystem)
It will place all the objects of your selected layers in an array.

Then you can loop thru the array by using 'Array Get Next'
and you can check the tag / name if needed.
Then you can do to that object what you want and loop back to the 'Array Get Next'


I almost got this working. But i can't figure out how to use the 'Array Get Next' action .. ? Do i store the result or how does this work?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 5946
    • View Profile
    • jinxtergames
Re: Help with TNT explosion and zombies
« Reply #5 on: February 27, 2021, 07:55:38 PM »
Hi.
here is a tutorial for array's :


InThAfAcE

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with TNT explosion and zombies
« Reply #6 on: March 01, 2021, 04:16:34 AM »
Thx guys. This helped me alot.

Still have one problem tho.. I get the objects from the array and can do things to them so thats all good. But how do i call a certain property of the zombies child? I tried just "set property" puppetmaster to dead on one zombie and dublicate the zombie  that didnt work. They don't work indepentenly when i do it this way.

Sorry it's so complicated in my head i have a hard time explaining it, hope someone gets what im talking about.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 5946
    • View Profile
    • jinxtergames
Re: Help with TNT explosion and zombies
« Reply #7 on: March 01, 2021, 05:32:31 AM »
Hi.
Wat property are you setting.

I think probably its best to handle that on a fsm on the prefab itself.

Then if you need to set some data, set that 1st. then use 'Send Event By Name' to trigger the set property.

Btw i found a post with some actions which might be useful for you :
https://hutonggames.com/playmakerforum/index.php?topic=12958.0

InThAfAcE

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with TNT explosion and zombies
« Reply #8 on: March 01, 2021, 07:19:01 AM »
Hi.
Wat property are you setting.

I think probably its best to handle that on a fsm on the prefab itself.

Then if you need to set some data, set that 1st. then use 'Send Event By Name' to trigger the set property.

Btw i found a post with some actions which might be useful for you :
https://hutonggames.com/playmakerforum/index.php?topic=12958.0

The property is something called state in puppetmaster. The idea is that the zombies in the array should all be set to the state "dead in the Puppetmaster component. But every one goes "dead" if one goes dead as it is right now. So i need a way to tell playmaker that it should only set the property of the specific gameobjects child in the array and not all of the zombies.