Expression Need to check distance

Get help using Construct 2

Post » Fri Apr 21, 2017 2:53 pm

Hi

when my Player sprite is close to block sprite (less than 100px)

and i click on box > box destroy

but when player is far (more than 100px)

clicking on block do nothing?
B
9
S
2
Posts: 34
Reputation: 674

Post » Fri Apr 21, 2017 3:23 pm

I would just use the line of sight behavior.
Image ImageImage
B
169
S
50
G
170
Posts: 8,292
Reputation: 108,728

Post » Fri Apr 21, 2017 3:32 pm

use the compare 2 values condition found under 'System'.

On Mouse.Click is clicking Box
if distance(Player.X,Player.Y,Box.X,Box,Y) <= 0 | Destroy Box
Image Image Image
B
29
S
11
G
27
Posts: 735
Reputation: 17,012

Post » Sat Apr 22, 2017 9:32 am

newt wrote:I would just use the line of sight behavior.


better for performance is use that behavior?
B
9
S
2
Posts: 34
Reputation: 674

Post » Sat Apr 22, 2017 2:42 pm

Given your conditions it would be about the same.
Image ImageImage
B
169
S
50
G
170
Posts: 8,292
Reputation: 108,728

Post » Sat Apr 22, 2017 2:44 pm

Oh yeah. I forgot you could select the barriers for line of sight.
Newt is right
Image Image Image
B
29
S
11
G
27
Posts: 735
Reputation: 17,012


Return to How do I....?

Who is online

Users browsing this forum: atmas, Baidu [Spider], engin20020, gamecorpstudio, IronRick, rbailey83, tarek2 and 21 guests