How do I reference a single instance from a family?

0 favourites
  • 3 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I have a number of Factory object instances on my screen, when they are touched, animation will play on the touched instance.

    But now when they are touched, all of the instances will play the animation.

    How can I reference only the object that I touched?

  • The reason this isn't working is because the conditions that pick the Family object don't also pick the specific Factory object, so your "Factory isDestroyed" condition picks all of the Factory objects.

    There are a few ways to get around this; the simplest is to shift your "isDestroyed" variable to the Family and then change all the conditions and actions referencing the Factory object to the Objects family.

    Another way would be to move all the Factory conditions and actions to a function; then, in the ObjectType = "Factory" subevent, pass the picked Object's UID to the function in a parameter and use that passed UID in the function to pick the Factory.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The reason this isn't working is because the conditions that pick the Family object don't also pick the specific Factory object, so your "Factory isDestroyed" condition picks all of the Factory objects.

    There are a few ways to get around this; the simplest is to shift your "isDestroyed" variable to the Family and then change all the conditions and actions referencing the Factory object to the Objects family.

    Another way would be to move all the Factory conditions and actions to a function; then, in the ObjectType = "Factory" subevent, pass the picked Object's UID to the function in a parameter and use that passed UID in the function to pick the Factory.

    Thanks, the UID method sounds good!

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