How do I compare variables?

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!

    Family FAM has variable SHED. If I create a condition FAM.Compare instance variable, the dropdown is empty. I expected to see SHED there.


    I've created a very simple card game.

    I created a few sprites.

    I created 2 families, DOG and FAM.

    I set sprites to families: DOG has 1 sprite. FAM has 3.

    I added a boolean variable "sheds" to both families.

    I've clicked each sprite in Families folder. I can see the instance variable sheds [DOG] or sheds [FAM]. I set each 'sheds' variable true or false.

    My layout has no sprites.

    OnStartLayout I System.create instance to create one DOG and one FAM (which I believe creates a random instance of any object in FAM family).

    Using System.EverySecond 0.1 I move it offscreen and destroy it, and create another FAM.

    I created a condition where DOG card overlaps FAM card. I want to add a second condition, if the FAM card has the same shed value as the DOG card, but can't

    First, I tried creating a condition CompareVariable on object FAM, but the dropdown list of variables is empty (I expected to see 'shed' since it's a FAM variable).

    Instead, I created the condition System.CompareTwoValues (DOG.sheds = FAM.sheds). This gives me wrong results (it matches cards whose 'sheds' is set different)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It sounds like you're looking for :

    DOG is overlapping FAM

    sub event- condition DOG is SHED(true) AND FAM is SHED (true)

    You add them together so they both must be true / matching.

  • You can't compare correctly the variables with the system expression if you didn't pick objects through another qualifier first.

    Also, the variables don't appear in the dropdown field because they are boolean.

    Use the condition "Is boolean instance variable set" instead, there you'll find your shed variable.

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