How to make 2D Object go forward

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.

This is what I mean by it going forward.

image

2 Likes

So I’m assuming that you are using GUIs for the objects?

1 Like

Yeah, I’m using GUIS, Frames, and ImageLabels.

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

You probably could tween or lerp it to the position but I’m not good with that kind of stuff.

Oh my! That the solution I was looking for! Big thanks!

Not gonna lie it might help people looking for this kind of answer too.

1 Like