How to make egg progressively shake faster

im making an egg system, and I was wondering how i can make an egg shake faster? Here is the current code which makes it shake at a linear rate, but I dont think it is a good effect for it to be a constant rate

hatchOneConnection = RunService.RenderStepped:Connect(function()
	local cf = CFrame.new(0,0,-eggMesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(0,0,math.sin(time() * 18)/2.3) 
	eggMesh:SetPrimaryPartCFrame(camera.CFrame * cf)
end)
1 Like

Perhaps you can add a new variable that controls speed that increases over time?

In it’s most basic form it would be something like this:

local speed = 1
hatchOneConnection = RunService.RenderStepped:Connect(function()
	local cf = CFrame.new(0,0,-eggMesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(0,0,math.sin(time() * 18 * speed)/2.3) 
	eggMesh:SetPrimaryPartCFrame(camera.CFrame * cf)
	speed += 0.05
end)

The increment should probably be adjusted to what “feels good”

1 Like

see thats what i thought at first too, but math.sin takes a degree measure as an input, and it goes up and down so what this does it it shakes slow, then fast, then slow, then fast in the opposite direction, then slow, etc
I printed math.sin(time() * 18 * speed) and these were some of the outputs
15:54:04.828 -0.7804947464070798 - Client - Hatch:156
15:54:04.847 0.42716795042077615 - Client - Hatch:156
15:54:04.863 0.5848291199618152 - Client - Hatch:156
15:54:04.882 -0.7003556932613887 - Client - Hatch:156
15:54:04.901 -0.8046773931326913 - Client - Hatch:156
15:54:04.919 0.9475346928300854 - Client - Hatch:156
15:54:04.935 0.3911165285028857 - Client - Hatch:156
15:54:04.955 -0.9011741021610888 - Client - Hatch:156
15:54:04.971 0.26330162728683026 - Client - Hatch:156
15:54:04.990 0.8998860318682157 - Client - Hatch:156
15:54:05.006 -0.32497047249158406 - Client - Hatch:156
15:54:05.026 -0.9178172785928159 - Client - Hatch:156
15:54:05.042 0.9526295282726469 - Client - Hatch:156
15:54:05.065 0.1672203084904782 - Client - Hatch:156
15:54:05.083 -0.7270649177333995 - Client - Hatch:156
15:54:05.100 0.8200668761897674 - Client - Hatch:156
15:54:05.124 0.365806946063401 - Client - Hatch:156
15:54:05.141 -0.1499592031940566 - Client - Hatch:156
15:54:05.159 0.9885092935158892 - Client - Hatch:156
15:54:05.175 -0.9510173917128826 - Client - Hatch:156
15:54:05.194 -0.6627738673110422 - Client - Hatch:156
15:54:05.210 0.9014227644085051 - Client - Hatch:156
15:54:05.229 -0.7667547896447846 - Client - Hatch:156
15:54:05.246 -0.23868073657565236 - Client - Hatch:156
15:54:05.265 0.5094406978727753 - Client - Hatch:156
15:54:05.281 -0.9998909857758118 - Client - Hatch:156
15:54:05.300 0.5098434967997436 - Client - Hatch:156
15:54:05.316 -0.33958464019022083 - Client - Hatch:156
15:54:05.335 -0.9882046392533581 - Client - Hatch:156
15:54:05.352 0.9994648632043673 - Client - Hatch:156
15:54:05.370 -0.6489741371496522 - Client - Hatch:156
15:54:05.387 -0.16034707110690366 - Client - Hatch:156

see how ti goes up and down

uh thats exactly what sin does?

image
its value is either 1 or -1

Its the delta value that changes.

So the dude solution will work

That will have the same speed, just different angle

nah its range is (-1,1), but it can be any value between them, and i can show you what happens when i use his solution

speed might be increasing too quickly, since time is likely a large number you may actually end up overflowing? Try adding speed instead of multiplying it just to see if that makes things better

2 Likes

Still didnt work, maybe a little better thjo

The overflow idea was probably on track. It’s probably getting too fast at the top end. Maybe put a top limit to the speed (like 50… or whatever, just so it doesn’t climb to inf. Start with limit at something low that you know won’t skip and keep raising the bar until it jitters)

local speed = 2 -- starting speed
-- inside runservice
local cf = CFrame.new(0,0,-eggMesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(0,0,math.sin(speed *time()))
-- ...
-- limiter
if speed < 50 then
	speed += 0.05
end