How do you pick an object by name?

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have a function that needs to be able to pick objects by combing strings (e.g. variable_foo&"bar"&variable_baz).

    I don't want to have to copy over object names into instance variables since that's going to increase the manual work significantly, so I'd like to be able to pick objects by names specifically.

    Is this possible to do, and if so, how can I achieve this?

    I feel like this should work:

    But for some reason it doesn't.

    Would appreciate some help on this.

    Thanks in advance.

    EDIT:

    I should probably mention that it's the picking object-aspect that's important, because I also need to know when it returns false (so that I can insert an "else" case to determine whether any objects matching the name exists). Otherwise I would've just used a foreach loop on a family and compared the ObjecTypeName.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you explain a bit more what you're actually trying to do?

    In your example your object name is "bar", so unless your comparison value resolves to be "bar" then it will not be picked.

    If you want to pick objects by name you could use a family. Place all your pickable objects in a family, pick the family object in the pick by comparison event and use family.ObjectTypeName expression. Then you can compare values that will resolve to the names of your objects.

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