Comparing the X position of two instances?

This forum is currently in read-only mode.
  • I have multiple instances of the same object (2-4 players), and I want them to push each other away when they collide ..so I want to know which one of them is on the right side and which one is one the left side from each other when they overlap...

    I tried to do it like this: (I'd use the 'Direction' value later in the pushing event)

    + Sprite overlaps Sprite

    + Sprite: X Less Than Sprite.X

    • Sprite: Set value 'Direction' to 1

    + Sprite overlaps Sprite

    + Sprite: X Greater Than Sprite.X

    • Sprite: Set value 'Direction' to -1

    but I guess construct doesn't know I want to compare the X of the two different instances that overlap like that..

    <font color=red>tldr:</font> how do I correctly compare the X of Sprite(1) from Sprite(2) ?

    (1) meaning instance1 and (2) meaning instance2 of same sprite

    Thanks beforehand!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)