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
10
S
2
Posts: 42
Reputation: 715

Post » Fri Apr 21, 2017 3:23 pm

I would just use the line of sight behavior.
Image ImageImage
B
171
S
50
G
179
Posts: 8,394
Reputation: 113,482

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
32
S
12
G
27
Posts: 761
Reputation: 17,244

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
10
S
2
Posts: 42
Reputation: 715

Post » Sat Apr 22, 2017 2:42 pm

Given your conditions it would be about the same.
Image ImageImage
B
171
S
50
G
179
Posts: 8,394
Reputation: 113,482

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
32
S
12
G
27
Posts: 761
Reputation: 17,244


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, CreativeMind and 22 guests