playMaker

Author Topic: Multiple trigger tags?  (Read 1490 times)

RobotGoggles

  • Playmaker Newbie
  • *
  • Posts: 35
Multiple trigger tags?
« on: January 12, 2019, 10:52:23 PM »
So the game I'm making involves four armies controlled by four players (or bots.) Right now the units are attacking (or healing) one another based on their tags: I have a player01 tag and a player02 tag. This works fine for two teams, but what about beyond that? Will I need three collisions being tested each frame for each unit? I was hoping there would be a way to test multiple tags in a string array or something.

Maybe I'm just going about the whole thing wrong?

When life hands you insomnia, make video games.

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Multiple trigger tags?
« Reply #1 on: January 12, 2019, 11:50:06 PM »
I'm kinda confused on what/how you're doing it all.  What Collisions are you checking if you are using tags to find objects?

Just taking a stab in the dark on it though what you can try is this.  Add each unit that belongs to each player into its own array.  Whenever you want to check for combat, have a Get closest game object action to find the closest one in each array.  Then you can decide if they are close enough to fight and if so which one to fight.

Let me know if it helps or if it doesn't and let me know a bit more on whats happening and I can try again :)

Thanks

RobotGoggles

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Multiple trigger tags?
« Reply #2 on: January 13, 2019, 12:04:53 AM »
I think that might work, but would end up very heavy.

Here's a bit more detail on the game: Each player's army is mostly self-driven. The only control you have over them is moving the player around the world: the mob units all follow their player, but whenever an enemy mob unit enters their personal trigger area (a neutral object each unit has with a collider on it) they stop following the player and go attack instead.

Right now the tag that collider is looking for is player02, but I'd like it to get set off by player 02, player03, or player04.

I thought of simply setting the trigger tag to something neutral, like "unit" and then check some string variable it has, but your army can get as big as 50 units or so, and every unit running that check against every teammate in the area would be very wasteful.
When life hands you insomnia, make video games.

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Multiple trigger tags?
« Reply #3 on: January 13, 2019, 12:37:18 AM »
Sounds like you're making something similar to what I'll be making too with my project :P

I'm not 100% on this and its a bit case sensitive but I've heard that collision boxes are actually heavier then getting the distance from objects.  Even when checking over 100 units at a time.  Also Arrays tend to be very light as well. Seems odd that it works that way but from what I read it seems to be the general case.

https://answers.unity.com/questions/348260/optimization-distance-vs-collisions.html

Once I get to the combat spot on my project, that is the road I was planning on taking.  I'd still suggest it.