playMaker

Author Topic: How would you proceed to make a merge 3 condition based on objects?  (Read 871 times)

PolyMad

  • Hero Member
  • *****
  • Posts: 545
I was thinking to store the collided object in array for each of the objects on the field, but I don't think this is optimal.

Another way is to keep a global array with all the objects on the field and light up their flags when they are in contact, but this seems too heavy to me too.

I think there should be a cleaner way to set this up, but I can't catch this up atm.

Anyone has any idea on how this could be made the clean way?
« Last Edit: September 06, 2021, 05:42:03 PM by PolyMad »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How would you proceed to make a merge 3 condition based on objects?
« Reply #1 on: September 07, 2021, 08:00:08 AM »
Hi.
So you have a bunch of objects and you want to 'flag' them if one is overlapping to another.

i would use array list and loop thru it every frame. to detect you could use boxcast.
but it depends on the objects form/size.
some other ways could be to check distance.
Or 'List Game Objects Inside Collider'

you could also have trigger events on each object but that might hit some performance if you have a lot of objects.

probably best to try some ways out on a separate scene and so some stress tests.

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: How would you proceed to make a merge 3 condition based on objects?
« Reply #2 on: September 07, 2021, 08:13:19 AM »
Thank you Dino!

"i would use array list and loop thru it every frame."

Isn't this expensive when you have tens of objects on the screen?
Additionally, you occur into the risk that the objects get deleted wrongly, it needs a lot of check in my opinion.

Anyway, I solved in a way I think it's quite classy: added a trigger to the objects, and when one of them touches 2... well it means that 3 are in contact, so I proceed with the due consequences!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How would you proceed to make a merge 3 condition based on objects?
« Reply #3 on: September 07, 2021, 05:58:29 PM »
Hi.
Having many Trigger events or Raycasts can become heavy actually

As each object is doing it at the same time every frame.

on game window turn on stats and start with a few and add more to see the difference.

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: How would you proceed to make a merge 3 condition based on objects?
« Reply #4 on: September 08, 2021, 04:39:33 AM »
OK, but they will only be calculated if the object is moving: when it falls asleep, I'll not be checking triggers  ;D