How do I solve this very odd boolean problem?

0 favourites
  • 6 posts
  • A little background on this first, we have unlockable costumes in our game which are controlled by Booleans.

    Each time the player picks up a costume the following function is ran

    We are testing this in debug and can see that a different boolean is being switched to True when we are trying any of the two current costumes.

    For example we INTERACT with a Costume_Trigger family member that has the Name 'Fire'

    It runs fine, but the end result is it switches the Costume_Unlocked_Sunshine to TRUE rather than the boolean in the code which is Costume_Unlocked_Fire

    Am I doing something wrong here? As there are no other references to Costume_Unlocked_Sunshine in the event sheets at all (other than the creation of the Boolean itself)

  • If you're saying that it switches a bool to true that doesn't exist in the function then it must be elsewhere in the code, or if that was an example and you mean it is switching a different one in the function to true then it could be any number of reasons. We can't see when the function is triggered.

    To make it foolproof I would bring the overlap family condition out of the function, and with that call the function, so it is like player overlaps costume, then call costume pick up function, this is more standard. You can send the family UID through the function as a parameter so you know which one was picked, in fact you would have to as things inside functions do not relate to instances picked by conditions outside of them, then use this family instance picked by UID to check its variable and such.

  • Maybe that boolean is true by default? If you are absolutely sure that there are no events that change that variable, then the only other possible explanation is that it gets restored from a saved game. Or it's a bug..

    Can you share your project file?

    And by the way, you need to remove "Trigger once", it should not be used inside functions.

  • Thank you lionz for replying, I might not have explained myself too clearly.

    The following screenshot shows all the references to costume_unlocked_sunshine in the entire series of event sheets

    So, as you can see there is no switching of the boolean at all (we just check it in a different area)

    We have made the adjustments to the function, so now the triggering of it looks like this

    Which runs the following function

    We interact with the Fire Costume trigger, (as you can see in the first screenshot) and it all runs but still the Costume_Unlocked_Sunshine boolean is switched and not the Costume_Unlocked_Fire one.

    So very strange!

  • Strange and impossible lol. You'll have to share the project file to work it out. Are you sure it's set to true, what makes you think so?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you're not picking any costume objects on overlap

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