How do I make one part point towards another?
#2
I made a tool to make a part point towards the mouse. Is it close enough to what you need?

[lua]
part = game.World.MyPart

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 == 1 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(script.Parent.MouseDragged, dragged)
[/lua]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)