How to make 2D Object go forward

Yes I’ve done it! it was just some trigonometry. It works but it might be inefficient to use in large quantities.

local ViewPortSize = workspace.Camera.ViewportSize
local SPEED = 2
while wait() do
local offset = script.Parent.Position + UDim2.new(math.cos(math.rad(script.Parent.Rotation))/ ViewPortSize.X * SPEED,0,math.sin(math.rad(script.Parent.Rotation))/ ViewPortSize.Y * SPEED,0)
script.Parent.Position = offset
end

This is meant to be in a localscript inside of the gui, but you can just change the code and put it anywhere.

3 Likes