Proximity Detection?!

Get help using Construct 2

Post » Fri Feb 21, 2014 2:16 am

Hi there!

So, the player has a flashlight to kill enemies. Is there a way that I can have the enemies slowly lose health as they approach the beam of the flashlight? It would be when they get fairly close to the light, but I'm unsure of how to do this if it's possible?
I was looking at this tutorial
https://www.scirra.com/tutorials/408/en ... yer/page-1

Maybe I'm just not seeing the connection?

Also my .capx:
https://www.dropbox.com/s/aks52qwbfe6ap ... inal8.capx

It's not much, because I'm just trying to work on the programming before I add in the graphics. Everything looks really dumb right now, sorry...
B
7
S
1
G
1
Posts: 9
Reputation: 1,677

Post » Fri Feb 21, 2014 2:41 am

You can do it with the distance command.

The way you use it is by adding a comparison from the system and in the first value you just write:

Distance(x1,y1,x2,y2) that will give you the distance between two objects.

In your case it would probably look something like this:

Distance(Flashlight.X, Flashlight.Y, Enemy.X, Enemy.Y) < 50

You can use the Distance function in any comparison event, so just use the one that fits, what you try to do.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848


Return to How do I....?

Who is online

Users browsing this forum: ASHKAR, brunopalermo, ItsAstro and 32 guests