How do I make one part point towards another?
#3
AWSOME, thanks! Here's my edited code, in case anyone else wants to use it:
[lua]
part = game.World.Box1

function normalizeVector(vec)
local m = math.sqrt(vec.x * vec.x + vec.y * vec.y)
return Vec2D(vec.x / m, vec.y / m)
end

function dragged(b, pos)
if b ~= nil then
local v = normalizeVector(Vec2D(pos.x - part.Position.x, pos.y - part.Position.y))
local a = math.deg(math.atan2(v.y, v.x))
part.Rotation = a
end end

link(game.World.Box2.PropertyChanged, function(prop, value)
if prop == "Position" then
dragged(game.World.Box2, value)
end end)
[/lua]

Box1 is the part that turns, it points at Box2.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)