How to create good sine effects for first person model?

Hello, I’m back from my break!

I still want to know how to sine a good sine wave animation. Problem is, I have no clue how to. Lemme put in details:

I want to be able to make it so, when I am idle, nothing happens. When I walk or run, it sines. And I want to be able to play animations while it sines.

I want to know how it works as well, if it breaks, I need to know what is breaking it. (Note, I don’t want to be baby-fed here. Just a brief explanation.)

Anything helps, Note that this is a local thing. It will all happen locally. Any questions may be asked too.

Do you mean like this? How to do the Arm Wave (Dance Moves Tutorials) Poppin John | MihranTV(@MIHRANKSTUDIOS) - YouTube

You will have to use the animation plugin in Roblox studio. You have to create a R15 rig. I don’t think R6 can do it as it doesn’t have enough articulation. Then you modify the movements for each step. There are quite a few tutorials on how to do animations in Roblox. Here’s a few…

https://developer.roblox.com/en-us/resources/build-it-play-it/2020summer/tier-1/creating-animations

Oh. No its for models. first person arms. I already know how to animate. I just need to know how to sine wave a model with scripts so i can play animations while its sining.

I assume you mean “bobbing”, in that case

You’ll need to have a variable for the offset (CFrame)

Every render step, you’d need to create a new CFrame
with the X axis set to: cos of (amount of time since the loop started) * (how quick you want it to be)
with the Y axis set to: abs of sin of (amount of time since the loop started) * (how quick you want it to be)

In the end, simply use PivotTo on the model with an argument of

camera.CFrame * offset
2 Likes

I’m not sure what you are referring too…unless it’s what Ahtoa mentioned, bobbing as you run where the view bounces up and down slightly? You do that with the camera offset.

I want it to be in a cosine method, goes in a Infinity on Apple motion. Going up and down is a little too simple.

Then you’re in luck. While researching something else, I came across what appears to be what you want, code included.

There’s some example code there that shows how to make a walking camera bobble effect, and it uses sine/cosine. Oh, and this code runs on the client.

1 Like

I will test this out. Thank you

Quick question, I don’t really want to make the camera move, I want the whole model to move. If I just move the camera, it looks funny. I couldn’t figure out how to move the model itself, anyway how?

Just use PivotTo and multiply the original WorldPivot with your Sine

local Model = workspace.Dummy

MODEL_PIVOT = Model.WorldPivot -- Store the original CFrame so it's now our constant
SINE = 0
TIME = 1
DISTANCE = 1

local elapseTime = 0
game:GetService("RunService").Heartbeat:Connect(function(dt)
	elapseTime += dt -- The reason I use DeltaTime is that it accounts for throttling
	SINE = math.sin(elapseTime*TIME)*DISTANCE
	
	Model:PivotTo(MODEL_PIVOT*CFrame.new(0,SINE,0))
end)

Ok so I did an attempt at this, it isn’t doing anything. Did I do something wrong?

local runservice = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local CurrentCamera = workspace.CurrentCamera
local humanoid = char:WaitForChild("Humanoid")

local arms = game.ReplicatedFirst.Model
local CONNECTED = false
local tool = script.Parent


tool.Equipped:Connect(function()
	AMS = arms:Clone()
	AMS["Left Arm"].CanCollide = false
	CONNECTED = true
	AMS.Parent = workspace
	connection = runservice.RenderStepped:Connect(function()
		if CONNECTED then
			AMS:SetPrimaryPartCFrame(CurrentCamera.CFrame * CFrame.new(0,0,-1))
			AMS["Left Arm"].CanCollide = false
			local MODEL_PIVOT = AMS.WorldPivot -- Store the original CFrame so it's now our constant
			local SINE = 0
			local TIME = 1
			local DISTANCE = 1

			local elapseTime = 0
			if humanoid.MoveDirection.Magnitude > 0 and CONNECTED then -- Is the character walking?
				game:GetService("RunService").Heartbeat:Connect(function(dt)
					elapseTime += dt -- The reason I use DeltaTime is that it accounts for throttling
					SINE = math.sin(elapseTime*TIME)*DISTANCE

					AMS:PivotTo(MODEL_PIVOT*CFrame.new(0,SINE,0))
				end)
			else

			end
		else
		end
	end)
end)


char:WaitForChild("Humanoid").Died:Connect(function()
	connection:Disconnect()
	AMS:Destroy()
end)

tool.Unequipped:Connect(function()
	CONNECTED = false
	connection:Disconnect()
	AMS:Destroy()
end)

Note: I mean a COSINE motion. Not an up and down motion.


This, but you get the point. I am trying to create a goal for it to continuously go in this motion when either walking or running. I probably mixed sine with cosine. Sorry