distance between 2 different objects

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I used this value (below) as the value of an instance variable (being set "Every tick")

    distance(Players.X, PirateSwordStand.X, Players.Y, PirateSwordStand.Y)

    I only want the horizontal distance (x axis) between "players" and "PirateSwordStand".

    If the horizontal distance between the 2 objects is less than 20, PirateSwordStand will stop walking (simulated, not by pressing buttons) and go to "Stance" animation.

    In what units are the distances being measured? I used 20 as the value but I don't have a clue about how long 20 units of distance is.

    <img src="http://neuropod.net/imagehost/uploads/a918f21ba7847ddd1fb86769ceac28f2.png" border="0" />

    The PirateSwordStand DOES NOT go to Stance animation and/or Attack animation.

    Also, how do I stop the walking of the platform ?

    Edit:

    PirateSwordStand is an enemy, so the movements/controls of the GoonBox are simulated.

    The codes shown in the pic results in the PirateSwordStand instances walking back and forth.

    What I want is for them to stop walking, change animation to Stance, then change to Attack animation, if and only if when the player is near them (per instance)

  • It should be distance(x1, y1, x2, y2) you have distance(x1, x2, y1, y2)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wiki Exspression

    Your Distance Calculation is false it should be (x1, y1, x2, y2)

    But if you want just check the horizontal distance better do:

    + System compare abs(x1 - x2) >= 20

    + Trigger once while true

    • your actions

    you dont need any every tick for that

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