Check if a player is near an object and clicking

Get help using Construct 2

Post » Sun Oct 07, 2012 7:58 pm

Hello,

I'm starting to build a top down platformer like the original zelda. How can I check if a player is clicking on a sprite and is also near them (on collison with?)

That way they will only be able to do damage to the sprite if they are next to them.

Thank you!

Sparty
B
5
S
1
G
1
Posts: 28
Reputation: 615

Post » Sun Oct 07, 2012 8:54 pm

That is very easy. Lets suppose the name of player sprite is Zelda and name of enemy sprite is Zombie.
FOR EVENT

MOUSE on click on the zombie
SYSTEM distance (zelda.X, zelda.Y,zombie.X, zombie.Y)
Is less or equal than 100

FOR ACTION
Zombie destroy (or substract from zombie "heath")

Its always better to put imagem but on this forum it so complicated.
And istead of 100, you can put any number.

AlexeyMak2012-10-07 20:56:30
B
21
S
4
G
1
Posts: 59
Reputation: 5,122

Post » Sun Oct 07, 2012 9:02 pm

That makes perfect sense except I can't find this distance comparison you mention.

Could this have to due with me using a free license?
B
5
S
1
G
1
Posts: 28
Reputation: 615

Post » Sun Oct 07, 2012 10:25 pm

The condition you're looking for is 'System: Compare two values'. Put "distance (zelda.X, zelda.Y,zombie.X, zombie.Y)" as the first value and 100 as the second.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests