I’m trying to make currently local script that makes 2D Object go forward even if it is rotated. The problem is I can’t really try to think of a solution to this problem. I have almost everything except this one thing.
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.