Hey, I’m not sure if this is what you’re looking for now, because I’ve not read the whole conversation thread, but based on the thread title does this help? You’ll need the mathlib from here:
https://developer.coronalabs.com/code/maths-library
Tap on the screen to create points along a line. Touch and drag around the screen to have the closest point on the line highlighted.
If this is what you’re looking for but you want it with physics, let me know and I’ll make the appropriate adjustements.

main.lua:
[lua]
– move along path
require(“mathlib”)
– physics not doing anything yet
require(“physics”)
physics.start()
physics.setGravity(0,10)
physics.setDrawMode(“hybrid”)
sWidth, sHeight = display.contentWidth, display.contentHeight
gravity = {x=0,y=10}
dots = display.newGroup()
lines = display.newGroup()
tracker = display.newGroup()
tracker.line = display.newGroup()
tracker.dot = display.newCircle(tracker,0,0,10)
function tap(e)
local dot = display.newCircle(dots,e.x,e.y,15)
dot:setFillColor(0,0,0,0)
dot:setStrokeColor(0,255,0)
dot.strokeWidth = 5
while (lines.numChildren > 0) do
lines[1]:removeSelf()
end
if (dots.numChildren > 1) then
for i=2, dots.numChildren do
local line = display.newLine(lines,dots[i-1].x,dots[i-1].y,dots[i].x,dots[i].y)
line.width = 5
line:setColor(0,0,255)
end
end
return true
end
Runtime:addEventListener(“tap”,tap)
function findClosestPoint(e)
local closestDist = 1000000
local closestPt = nil
for i=2, dots.numChildren do
local pt = GetClosestPoint( dots[i-1], dots[i], e )
local len = lengthOf( pt, e )
if (len < closestDist) then
closestDist = len
closestPt = pt
end
end
return closestPt
end
function refreshTrack(e)
local pt = findClosestPoint(e)
tracker.dot.x, tracker.dot.y = pt.x, pt.y
tracker.line:removeSelf()
tracker.line = display.newLine(tracker,e.x,e.y,pt.x,pt.y)
end
function touch(e)
if (e.phase == “began”) then
tracker.alpha = 1
refreshTrack(e)
elseif (e.phase == “moved”) then
refreshTrack(e)
else
tracker.alpha = 0
end
return true
end
Runtime:addEventListener(“touch”,touch)
[/lua] [import]uid: 8271 topic_id: 35544 reply_id: 145182[/import]

