Laedere
|
  |
| Joined: 17 Jun 2013 |
| Total Posts: 23601 |
|
|
| 05 Dec 2013 11:25 PM |
So I made a distance formula, to find the distance between to given points. Is there any bugs you can find?
cor1 = {1, 2} cor2 = {3, 4}
x1 = cor1[1] x2 = cor2[1] y1 = cor1[2] y2 = cor2[2]
one = x2-x1 oneone = one^2 two = y2-y1 twoone = two^2
threeone = oneone + twoone print(math.sqrt(threeone)) |
|
|
| Report Abuse |
|
|
| |
|
|
| 06 Dec 2013 02:26 AM |
| Not Really. But I'm not very good at the "Distance" scripts.... |
|
|
| Report Abuse |
|
|
| |
|
einsteinK
|
  |
| Joined: 22 May 2011 |
| Total Posts: 1015 |
|
|
| 06 Dec 2013 04:09 AM |
Like KiWi said:
local a = Vector3.new(x,y,z) local b = Vector3.new(x,y,z)
local dist = (a-b).magnitude print("Distance:",dist)
If you want to only use X and Y, use 0 for Z (or leave Z for automatic zero) |
|
|
| Report Abuse |
|
|
| |
|