Hello!
So i have a game that is pretty similar to Bee Swarm Simulator, a very popular simulator on ROBLOX, and im trying to replicate the Bobbing that BSS has for their Bees!
BSS Bob:
It’s a very small detail and small rotation that is probably less than 5 radians, but adds so much life into every Bee.
So i tried to replicate it for my game, and it does work, but it has some weird issues, that i have no idea on how to fix, one thing to keep in mind before trying to help me is i do the lerps for bobbing while lerping for other things like movement, which is something that Bee Swarm Simulator also does.
But i don’t know how they pull it off, and all i do is lerp the Z axis for the CFrame.Angles of a Bee’s CFrame, the X and Y i lerp to whatever the value is currently at, anyways here’s the issues:
1 - Bees just get random strokes when they move down:
2 - Bees just look down for some reason???
Another thing to note is that when the Bee is stationary the Bobbing works fine most of the time.
Here’s the code i do for the Bee Bobbing:
( This Function runs once a new Bee is added into the workspace )
As you might also notice, each Bee has an attribute named “Do_Bob”, this attribute controls when
a Bee is allowed to bob, i implemented this so i could try and fix the 2 issues above, by implementing them, when the Bee looks at a different direction for example, which could mess up with the Bobbing?
But i don’t think it’s necessary.
I can also give the rest of the Code for animating the Bee if more information is needed
Hopefully someone can help!
local function Animate_Bee_Bob(Bee_Model: Model): ()
local Connection: RBXScriptConnection = nil;
local Bob_Alpha = 0;
local Done_Bob_Left = false;
Bee_Model:SetAttribute("Bob", 5);
Connection = Run_Service.Heartbeat:Connect(function(deltaTime)
if not Bee_Model.PrimaryPart then
Connection:Disconnect();
return;
end
if Bee_Model:GetAttribute("Do_Bob") then
Bob_Alpha = TWEEN_SERVICE:GetValue(Bob_Alpha + deltaTime / BOB_TIME, Enum.EasingStyle.Linear, Enum.EasingDirection.In);
Bee_Model.PrimaryPart.CFrame = Bee_Model.PrimaryPart.CFrame:Lerp(CFrame.new(Bee_Model.PrimaryPart.Position) * CFrame.Angles(math.rad(Bee_Model.PrimaryPart.Rotation.X), math.rad(Bee_Model.PrimaryPart.Rotation.Y), math.rad(Bee_Model:GetAttribute("Bob"))), Bob_Alpha);
if Bob_Alpha == 1 then
local Current_Bob = Bee_Model:GetAttribute("Bob");
Bob_Alpha = 0;
if Current_Bob == 5 then
Done_Bob_Left = true;
Bee_Model:SetAttribute("Bob", 0);
return;
end
if Current_Bob == -5 then
Done_Bob_Left = false;
Bee_Model:SetAttribute("Bob", 0);
return;
end
if Current_Bob == 0 then
if Done_Bob_Left then
Bee_Model:SetAttribute("Bob", -5);
else
Bee_Model:SetAttribute("Bob", 5);
end
end
end
end
end)
end