toggle menu
Categories
Discussions
Dashboard
Sign In
·
Register
Sign In
·
Register
Categories
Discussions
Dashboard
Sign In
·
Register
×
Home
›
GameSalad 101
›
Working with GS (Mac)
how i get distance from x and y individual between two objects?
guilleface
Member
Posts:
1,014
February 2012
edited February 2012
in
Working with GS (Mac)
hi, i know how to use magnitude,but i need this time x and y in a separated rule. thanks
Comments
morphinegamingmachine
Member, PRO
Posts:
449
February 2012
you mean u need to know the distance away from each other, not the y distance, and then the x distance??
example
actor a is at point x=10 y= 24
actor b is at point x=7 y=28
they r 3 away in the x, and 4 away in the y. which means the distanced between them it 5
pathogorean thrym for the hypotenuse
a^2+b^2=c^2
so diagonal distance= square root of (difference in x ^2 + difference in y^2)
JohnPapiomitis
Member
Posts:
6,256
February 2012
edited February 2012
i think you can do magnitude(self.position.x,object.x)
subtracting the objects x from the players x might also work too
Clouds
Member
Posts:
1,599
February 2012
Ignore morphinegamingmachine and JohnPapiomitis with all their clever maths . . .
Just hold a ruler up against the screen and measure the distances, you can write the number on the back of your hand to save paper.
Glad I could help.
Sign In
or
Register
to comment.
Comments
example
actor a is at point x=10 y= 24
actor b is at point x=7 y=28
they r 3 away in the x, and 4 away in the y. which means the distanced between them it 5
pathogorean thrym for the hypotenuse
a^2+b^2=c^2
so diagonal distance= square root of (difference in x ^2 + difference in y^2)
subtracting the objects x from the players x might also work too
Just hold a ruler up against the screen and measure the distances, you can write the number on the back of your hand to save paper.
Glad I could help.