How would I make my viewmodel move in an infinity type loop

How would I make my viewmodel move in an infinity loop
Something like this.

1 Like

An easy way is to draw a Lissajous curve!!! Thought I would never get to talk about these!!

You should also check out the leminsicate of Bernoulli, or the lemniscate of Gerono !! They are similar to what you want–and just as cool!

Gerono’s lemniscate also has a parametrization given by a lissajous curve.

A simple parametrization for an “infinity sign” can be given by:
x = a * cos(t / 2)
y = b * sin(t)
0 < t < 4πif you are going to draw all points and do not want overlapping.
-∞ < a < ∞
-∞ < b < ∞

You might be looking for a curve with a lower amplitude, so try this:
x = a * cos(t / 2)
y = b * sin(t) / 2
0 < t < 4π
-∞ < a < ∞
-∞ < b < ∞

Here is a code example of a script inside a Part and the script will modify the part’s position to follow an infinity path.

local RunService = game:GetService("RunService")
local Part = script.Parent

local a = 10
local b = 5

local t = 0
local dt = 1 / 10

local function Draw()
	local X = a * math.cos(t / 2)
	local Y = b * math.sin(t)
	local Z = 0
	
	local CF = CFrame.new(X, Y, Z)
	
	Part.CFrame = CF
	t += dt
end

RunService.Heartbeat:Connect(Draw)

5 Likes

Thank you so much! This is going to work so well!

Hello, today I was learning trigonometry, and I discovered this method using cosine and sine:

local runService = game:GetService("RunService")
local part = script.Parent
local radius = 10
local degree = 0
local center = part.Position

while runService.Heartbeat:Wait() do
	degree += 5
	
	local x = math.cos(math.rad(degree)) * radius
	local y = math.sin(math.rad(degree * 2)) * radius

	part.Position = center + Vector3.new(x, y, 1)
end

I hope this was helpful.