gmullinix's Forum Posts

  • 2 posts
  • Happy to report that I figured this out thanks to the post titled: How do I know which instance has which IID? (I can't post links so I guess just search the forum for it.)

    For anyone who has the same problem/question:

    -- I added a new instance variable to my SpriteCustomer called "SelectedCustomer", changed it to a Boolean Variable and left the default at false.

    -- In Step 1 as described in my above post, I added an action to toggle the "SelectedCustomer" variable. This sets the variable to "true".

    -- Once the player avatar arrives at the customer position, I added a second condition to look for the SpriteCustomer instance that had "SelectedCustomer" set to true. The exact condition I clicked was "Is boolean instance variable set" and then chose the "SelectedCustomer" variable from the dropdown.

    -- The actions to add 1 to happiness level worked perfectly.

    -- Then I added one last action to toggle the "SelectedCustomer" variable again. This sets the variable back to "false" so it's ready for me to click the next customer.

    Here's a picture. All the new stuff I added is underlined in blue.

    The logic is still a bit fragile - for example if I click a bunch of customers like crazy the game doesn't quite know what to do. But for demo purposes it's great.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi everyone,

    Here's what I'm trying to achieve:

    1. Player clicks on a customer.

    2. Player's avatar walks (pathfinds) to that customer.

    3. Once the avatar has arrived at the customer's location, that customer's happiness level increases (this is an instance variable).

    The problem I'm having is that between steps 1 and 3, I "lose" the ability to know what customer instance was clicked on in step 1, so I'm then unable to modify the correct instance in step 3. It works if I modify the instance's variable in step 1 (since I still know what's been clicked on), but I need it to happen in step 3.

    Here's a screenshot of my logic with additional details. The way this logic is currently set up, when I refer to to "Sprite Customer > Add 1 to HappinessLevel" in the final step, it increases the happiness score of ALL customers, not just the one that was originally clicked.I read into storing the instance's UID to refer to it later, but got stumped (and it seems like bad practice?). I also looked into nesting my actions and conditions so I wouldn't lose the customer information, but then I was limited in the pathfinding behaviors I was able to use, so that didn't work either.

    Any help is appreciated. I've attached the capx file for the game. Thank you for reading!

  • 2 posts