I don't understand Distance expressions. Help?

Get help using Construct 2

Post » Thu Aug 29, 2013 4:01 am

I suck at math and I'd like to make my enemies do more than just walk back and forth all the time. Can someone tell me how to use the distance expressions?
B
10
S
4
G
1
Posts: 159
Reputation: 1,933

Post » Thu Aug 29, 2013 4:19 am

distance(x1, y1, x2, y2) Calculate distance between to points

It's pretty self explanatory. Say you have a player and an enemy
distance(player.x, player.y, enemy.x, enemy.y) will return the distance from those 2 objects.

So if you want the enemy to shoot when the player is closer than 200 pixels:

If distance(player.x, player.y, enemy.x, enemy.y) < 200
   - Trigger enemy shooting event/function/group

B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Thu Aug 29, 2013 12:44 pm

What's the event/function/group about?
B
10
S
4
G
1
Posts: 159
Reputation: 1,933

Post » Thu Aug 29, 2013 1:05 pm

How do I put the distance first? Do I need to select the player or the enemy first?
B
10
S
4
G
1
Posts: 159
Reputation: 1,933


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 7 guests