0 Favourites

How do I pick an instance once/get family variable <SOLVED>

  • Just two quick issues:

    1. - When pressing a key, a boolean toggles the bubble text system. The problem is that if you move closer to other interactive object (they are stored in a family) the bubble will change it´s position too, I would like to pick the closest only once. I´ve been trying it for a while but found no result.

    2. - All interactive objects are stored in a family, and each one has a "dialog" instance variable with a line of text (no conversation is intended). No problem when picking closest member to the player, but I´ve searched around and found no way to get the instance variable of the already picked object of the family.

    The code´s a mess, though, i´ll try to simplify it meanwhile.

    Any help would be greatly appreciated.

  • First - you don't need the system every tick condition in event 5 and 6, for they will be evaluated every tick regardless..

    Second - you are picking the nearest talk every tick, which is why the bubble moves..

    I guess adding an instance variable to the triangle "TalkUID" would do the trick..

    add a triangle set "TalkUID" to talk.UID to the on space bar pressed - event

    and replace the pick nearest talk condition in the events below to pick talk by comparison : talk.uid = triangle.TalkUID

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Works like a charm! Thanks a lot for the quick response, LittleStain ! But do you have any idea on how to get the dialog variable from a "talk" object? It´s on the second image of my first post, i´ve been wondering for a while but I have absolute no idea on how to approach it!

  • set text to talk.dialogue?

    if dialogue is an instance variable of talk this should work..

  • No, dialog is an instance variable that every "talk" member has, with different text. Is there any way to get that instance variable from the picked object?

  • Yes, like I said..

    I'm not sure why you'd say no:

    • if dialogue is an instance variable of talk
    • dialog is an instance variable that every "talk" member has

    If you set the text to talk.dialogue instead of player.dialogue everything should work as intended..

  • My bad, I created a different "dialog" instance variable for each member individually instead of creating a family instance variable and setting different text for each object.

    Thanks inmensely, LittleStain and I´m really sorry, terribly bad with explanations sometimes...

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