Compare two variables or more

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Ok, this may sound simple but I couldn't do it. Any help would be welcome!

    So, I have these three objects (Target, ObjectA and ObjectB). Their frames are determined by three different variables (every tick set object frame to that variable). Each frame is a different geometric form. Example: Frame 3 is a square for all objects.

    What i'm trying to do here is that every time the user presses space bar, the system compares if there are any objects that are identical. If so, then set the "ObjectIdentical" variable to 1. If not, then its 0.

    There's an image explaining what i'm thinking: http://imgur.com/fe9m0TB

    As Always, thank you in advance, community!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Create a global variable for each object with the same name of the object and wright conditions for each

    Target > Animation frame = 0 > System > Set Value > Target_Variable = 0

    Target > Animation frame = 1 > System > Set Value > Target_Variable = 1

    Target > Animation frame = 2 > System > Set Value > Target_Variable = 2

    Target > Animation frame = 3 > System > Set Value > Target_Variable = 3

    Object1 > Animation frame = 0 > System > Set Value > Object1_Variable = 0

    Object1 > Animation frame = 1 > System > Set Value > Object1_Variable = 1

    Object1 > Animation frame = 2 > System > Set Value > Object1_Variable = 2

    Object1 > Animation frame = 3 > System > Set Value > Object1_Variable = 3

    Object2 > Animation frame = 0 > System > Set Value > Object2_Variable = 0

    Object2 > Animation frame = 1 > System > Set Value > Object2_Variable = 1

    Object2 > Animation frame = 2 > System > Set Value > Object2_Variable = 2

    Object2 > Animation frame = 3 > System > Set Value > Object2_Variable = 3

    Then

    Create a function and put the following conditions in it

    System > Target_Varable = Object1_Variable > Set Value ObjectIdentical = 1

    Else > (Do Nothing)

    System > Target_Varable = Object2_Variable > Set Value ObjectIdentical = 1

    Else > (Do Nothing)

    When you press spacer bar, call the function. The default value of ObjectIdentical should be 0.

    I don't know the particulars of your code but when the game resets with new animation frames to compare, you need to create or add an "Event" to set the value of ObjectIdentical variable back to 0.

    I also don't think you need to use every tick. When a global variable has a value, it is always every tick.

    As I just thought about it, you could just do this:

    Just create the Target_Varable and write it like this:

    System > Target_Varable = Object1.AnimationFrame > Set Value ObjectIdentical = 1

    Else > (Do Nothing)

    System > Target_Varable = Object2.AnimationFrame > Set Value ObjectIdentical = 1

    Else > (Do Nothing)

    Hope this helps

  • Got it to work!

    Thank you!

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