I'm missing something about distance expression

Get help using Construct 2

Post » Sat Apr 06, 2013 7:24 pm

Hello everyone.

I think I overdid myself today and now can't even see the most basic things I need to see. I checked the forums and tutorials and some capx's, but still no find.

Here is the thing: I want my turrets to play a "shutdown" animation when player moves a set distance away from them, ie the turret loses it's target. I'm reading everywhere a system.distance expression but I can't find a way to implement the desired effect.

The reverse is easy, when target acquired I play the "powering up" animation. But there is no set "on target lost" condition for turrets.

Help ? :)
B
16
S
4
G
1
Posts: 332
Reputation: 3,016

Post » Sat Apr 06, 2013 7:28 pm

If you're using the distance expression:

distance(Turret.X, Turret.Y, Target.X, Target.Y) > YourRange

If your distance is greater than the variable YourRange, perform actions.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sat Apr 06, 2013 8:06 pm

Hey Nimitrix, I cant place a distance condition anywhere on conditions? How do I create a condition including a distance expression?
B
16
S
4
G
1
Posts: 332
Reputation: 3,016

Post » Sat Apr 06, 2013 8:25 pm

[QUOTE=Windwalker] Hey Nimitrix, I cant place a distance condition anywhere on conditions? How do I create a condition including a distance expression?
[/QUOTE]

Use any comparison condition, like one you'll find for instance variables. Place the distance formula in the empty box. If necessary, system menu offers 'compare two values' where you can compare any two values you choose.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sun Apr 07, 2013 12:22 pm

[QUOTE=vee41] [QUOTE=Windwalker] Hey Nimitrix, I cant place a distance condition anywhere on conditions? How do I create a condition including a distance expression?
[/QUOTE]

Use any comparison condition, like one you'll find for instance variables. Place the distance formula in the empty box. If necessary, system menu offers 'compare two values' where you can compare any two values you choose.[/QUOTE]

Thanks Nimitrix, yesterday late into night I solved it out thanks to you :)
B
16
S
4
G
1
Posts: 332
Reputation: 3,016


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jul, randomly and 24 guests