playMaker

Author Topic: How to get the count of a given object in an array  (Read 748 times)

RobotGoggles

  • Playmaker Newbie
  • *
  • Posts: 35
How to get the count of a given object in an array
« on: March 07, 2021, 11:46:55 PM »
I have an array that lists all of the summoned units a player has in their control. I'm trying to get the number of instances of a specific kind of unit and can't seem to figure it out.

I tried using ArrayMaker and the "Array List Contains Count" action, but it returns nothing, but I can see that the Array is being populated with the GameObject in question. Can anyone think of an alternate solution that would work here?
When life hands you insomnia, make video games.

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: How to get the count of a given object in an array
« Reply #1 on: December 08, 2023, 06:44:20 PM »
Did you ever find a solution?  I'm facing something similar...

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: How to get the count of a given object in an array
« Reply #2 on: December 09, 2023, 04:47:25 AM »
well if you are look for the game object (Prefab) , it is not the same game object, it is a instance of that object so it is not the same object.

so you can for example loop thru the array and compare a 'Tag' or name