How does the distance commands work?

Get help using Construct 2

Post » Wed Nov 25, 2015 12:34 am

Having trouble finding/figuring this out, I know the distance command returns the distance between the X and Y of an object compared to another.

But how do I use this? I'm trying to save this distance value and compare it because half way to the distance of another object I want to do other stuff. So does anyone know of an easy to to remember all of this distance checking, its confusing me bad.
Basically, I want to check one objects distance from another, using the dist() function returns the distance in pixels between these two objects? So I can do math on it like this?

dist(myObject1.x, myObject1.y, otherObject2.x, otherObject2.y) < distancetestvalue
trigger event

will this do:
this distance from the object less than this range

and which object goes where , how do I remembher this stuff/ Anyone know of a beginners guide to programmer website that can explain this basic geometry/trigonometry to me? I canrt figure out atan2 either. I know they do what they do, but not why they do it or any special rules I should follow when using the commands.
B
5
S
1
Posts: 68
Reputation: 515

Post » Wed Nov 25, 2015 12:45 am

Well your explanation confuses me, while I understand..

distance(x1,y1,x2,y2) returns the distance in pixels between point 1 and point2
angle(x1,y1,x2,y2) returns the angle between point 1 and point 2

to get halfway between the two objects you could move something 0.5*distance() at angle()

another way would be to create an object at x=lerp(x1,x2,0.5) y=lerp(y1,y2,0.5)

If you use
dist(myObject1.x, myObject1.y, otherObject2.x, otherObject2.y) < distancetestvalue

it will check if object2 is within a radius of distancetestvalue of object1
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Nov 25, 2015 1:20 am

wow thanks alot for the explination but, im kinda confused, what does lerp do?

anyway, Iddint know the order was important for distance() and thanks for that. basically I want to check objects distances within radiuses, yes. But the other stuff sounds important too. I dont have a very good understanding of this so I'm trying to figure out all the distance functions since its important for me to know where stuff is.
B
5
S
1
Posts: 68
Reputation: 515

Post » Wed Nov 25, 2015 10:32 am

solved
B
33
S
9
G
3
Posts: 280
Reputation: 4,287


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests