null
nil
-
0
Katamari
true
-
false
Script
--[[ Creative Commons Zero
Concept stolen from Katamari Damacy by Namco
Have fun ;) -pengo
]]--
local config = {
clumpBudget = 100;
}
local bin = script.Parent
local ball
local clumpsRemaining = 0
local hooks, touching = {}, {}
function hook(connection)
table.insert(hooks, connection)
end
function clearHooks()
while #hooks > 0 do
table.remove(hooks):disconnect()
end
end
bin.ballPtr.Changed:connect(function(value)
clearHooks()
ball = value
bin.mass.Value = ball:GetMass()
touching = {}
ball.Touched:connect(onTouched)
end)
function clump(x)
local weld = Instance.new("Weld", ball)
weld.C0 = ball.CFrame:toObjectSpace(x.CFrame)
weld.Part0 = ball
weld.Part1 = x
touching[x] = true
bin.mass.Value = bin.mass.Value + x:GetMass()
hook(x.Touched:connect(onTouched))
end
function onTouched(x)
if x.Anchored
or touching[x]
or x:GetMass() > bin.mass.Value
or x:IsDescendantOf(bin.Parent.Parent.Character)
then
return
end
x:BreakJoints()
if clumpsRemaining > 0 then
clump(x)
clumpsRemaining = clumpsRemaining - 1
end
end
while wait(1) do
clumpsRemaining = config.clumpBudget
end
true
-
false
LocalScript
--[[ Creative Commons Zero
Concept stolen from Katamari Damacy (Clump Spirit) by Namco
Have fun ;) -pengo, 1 October 2024
]]--
local config = {
size = 7;
speed = 8;
torque = 30000;
}
local bin = script.Parent
local localplayer = game.Players.LocalPlayer
local ball, torque, camera
function getPlayerCamera()
for _, child in pairs(workspace:GetChildren()) do
if child.className == "Camera"
and child.CameraSubject == localplayer.Character.Humanoid then
return child
end
end
end
function makeBall(parent)
ball = Instance.new("Part", parent)
ball.Name = "katamari"
ball.Shape = "Ball"
ball.Size = Vector3.new(1, 1, 1) * config.size
ball.Position = localplayer.Character.PrimaryPart.Position
ball.BrickColor = BrickColor.new("Bright violet")
ball.Transparency = 0.2
ball.Reflectance = 0.2
ball.TopSurface = "Smooth"
ball.BottomSurface = "Smooth"
ball.Friction = 2
torque = Instance.new("BodyAngularVelocity", ball)
torque.angularvelocity = Vector3.new(0, 0, 0)
bin.ballPtr.Value = ball
end
bin.Selected:connect(function(mouse)
makeBall(localplayer.Character)
camera = getPlayerCamera()
camera.CameraType = "Follow"
camera.CameraSubject = ball
mouse.Button1Down:connect(function()
torque.maxTorque = Vector3.new(1, 1, 1) * bin.mass.Value * config.torque
end)
mouse.Button1Up:connect(function()
torque.maxTorque = Vector3.new(0, 0, 0)
end)
mouse.Move:connect(function()
local wishDir = mouse.Hit.p - ball.Position
torque.angularvelocity = Vector3.new(wishDir.z, 0, -wishDir.x).unit * config.speed
end)
end)
bin.Deselected:connect(function()
if ball then
ball:Remove()
end
camera.CameraSubject = localplayer.Character.Humanoid
end)
true
-
ballPtr
[null]
true
-
mass
0
true