distance between 2 different objects

Get help using Construct 2

Post » Thu Oct 24, 2013 1:26 pm

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.



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)sgn152013-10-24 13:28:54
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Thu Oct 24, 2013 2:53 pm

It should be distance(x1, y1, x2, y2) you have distance(x1, x2, y1, y2)
B
46
S
14
G
7
Posts: 603
Reputation: 8,096

Post » Thu Oct 24, 2013 3:11 pm

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 thatDarklinki2013-10-24 15:12:38
B
15
S
6
G
6
Posts: 512
Reputation: 5,555


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests