03-10-2013, 01:26 PM
You'd have to set a limit on how far away the part is from the gravity source.
This could be done in about 3 lines of code, actually. This might not work perfectly, since my math skills are weak at best, but, basically, I think it would work like this:
add one line to the top of the script:
gravradius = 50
then, add after this bit:
local xdist = gravitypoint.x - object.Position.x
local ydist = gravitypoint.y - object.Position.y
--new stuff
local totaldist = math.sqrt((xdist * xdist) + (ydist * ydist))
--pythagorean theorem :]
if totaldist < gravradius then
-- do rest of script; just make sure to add an extra end :]
This could be done in about 3 lines of code, actually. This might not work perfectly, since my math skills are weak at best, but, basically, I think it would work like this:
add one line to the top of the script:
gravradius = 50
then, add after this bit:
local xdist = gravitypoint.x - object.Position.x
local ydist = gravitypoint.y - object.Position.y
--new stuff
local totaldist = math.sqrt((xdist * xdist) + (ydist * ydist))
--pythagorean theorem :]
if totaldist < gravradius then
-- do rest of script; just make sure to add an extra end :]
![[Image: iwn8gk.gif]](http://i46.tinypic.com/iwn8gk.gif)