How do I check conditions for multiple object before doing an action?

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • The player can drop items. If 2 items collide they should make a new item. The items have a name variable telling the game what they are. How do I check the name of each one separately before deciding what to do when they collide?

    If item is overlapping item

    item 1 name is "STICK"

    item 2 name is "STICK"

    Then destroy item (both of them)

    Then spawn item and set name to "CLUB"

    I have tried sub events but it does not seem to work. I might have done it incorrectly since I am not 100% sure how to structure them though.

  • Are they different objects or are instances of the same object?

    If they are instances of the same object you can use families:

    item overlaps family:

    -----> item 1 name is "STICK"

    -----> Family name is "STICK"

  • The item is actually a family. So is there a way to check each instance of the family separately?

  • The item is actually a family. So is there a way to check each instance of the family separately?

    Yes you can check each instance independently by using "For Each"

    item overlaps Family:

    ----->For Each Family:

    ---------> Check whatever you need here

    However, you don't need to do a for each if just want to find out two matching items.

    A simple check it should work:

    item overlaps Family:

    ------> "item Name" = "Family.item name": destroy item & destroy family

    Edit:

    Unless you are overlapping more than two items, in that case, the "For Each" will the best option to find the first matching pair.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks :D

  • Np

    Glad you sort it out)

  • I actually tried another method and used the "Pick nth instance" condition for a subevent after the overlapping event which let me pick each item specifically to check their names. It seems to work well so far. Just thought you might know.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)