How to make a smoothly moving ball

My new game is based on being inside a ball and rolling around inside of it. I’ve managed to spawn myself inside a ball yet it doesn’t feel smooth compared to another ball game:

https://www.roblox.com/games/162537373/Super-Blocky-Ball

https://gyazo.com/9c46ed0d0e753390112557dfd47863b6
https://gyazo.com/0af799df7f42d70999214dd3e314b334

I want to be able to move around as in the examples above from the Super Block Ball game, the bottom ones are the ones in my game

https://gyazo.com/9c46ed0d0e753390112557dfd47863b6
https://gyazo.com/0af799df7f42d70999214dd3e314b334

Is there a way I can closely mimic the movement of the ball in Super Blocky Ball? I’m fairly novice in scripting though here is my current script:

local Value = 2

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local HRP = char:WaitForChild("HumanoidRootPart")
		local marble = Instance.new("Part")
		marble.Size = Vector3.new(8,8,8)
		marble.BrickColor = BrickColor.Random()
		marble.Transparency = .5
		marble.Shape = Enum.PartType.Ball
		marble.Parent = char
		marble.Material = Enum.Material.SmoothPlastic
		marble.Name = "Sphere"
		local Velocity = Instance.new("BodyAngularVelocity")
		Velocity.Parent = marble
		local Hum = char:WaitForChild("Humanoid")
		local Weld = Instance.new("Weld")
		Weld.Parent = marble
		Weld.Part0 = HRP
		Weld.Part1 = marble
		Hum.PlatformStand = true


		local JumpScript = script.Effect:Clone()
		JumpScript.Disabled = false
		JumpScript.Parent = HRP.Parent






		while true do
			wait()
			marble.BodyAngularVelocity.AngularVelocity = Vector3.new(char.Humanoid.MoveDirection.z * 20000,0,char.Humanoid.MoveDirection.x * -20000)
			marble.BodyAngularVelocity.MaxTorque = Vector3.new(Value * 10000,Value * 10000,Value * 10000)
			if char.Humanoid.MoveDirection == Vector3.new(0,0,0) then
				marble.BodyAngularVelocity.MaxTorque = Vector3.new(0,0,0)
			end
		end
	end)
end)

Jump script parented to previous:

script.Parent.Humanoid.Changed:Connect(function()

	if script.Parent.Humanoid.Jump == true then
		local Velocity2 = Instance.new("BodyForce", script.Parent.Sphere)

		Velocity2.Force = Vector3.new(0, 180000, 0)
	
		game.Debris:AddItem(Velocity2,0.1)

		script.Disabled = true

		wait(1)
		script.Disabled = false

	end

end)

1 Like

CFrames have a property called LookVector which is a Vector3 (unit vector) that points in the direction for forward face of the object.

Dont take my word for it but my guess is that super blocky ball messed with the PlayerModule to get their control system. No idea how you’d go about doing that.

I made a game where you control a snowball that just uses body forces. If the force is week enough the player wont be able to move upward. To do it i made the player not collide, Massless, and lowered density as low as possible, then welded to the ball. Then i made a bodyForce, parented it to the ball and set the force equal to the player camera’s lookvector * some amount to magnify the force to my liking. If youd like to check it out let me know and ill have to show you because you need to trigger the snowball effect and its kinda hidden.

I’m interested, show me the game

here it is

let me know when you join so i can show you

K its getting late so youll have to play on ur own.

To trigger the event walk on the planks close to where you spawn.

I need to correct myself when i said i just made the force small to keep players from floating. This was not how i programmed it. I use a body force but i multiple the Force property with Vector3.new(1,0,1) so like this
bF.Force = bF.Force * Vector3.new(1,0,1).

This cancels any upward force incase the LookVector is pointing up

Personally I wouldn’t roll the ball as you can’t really control acceleration and direction change all that well. The ball might start sliding if you add too much angular velocity.

So, I recommend switching to LinearVelocity. There you can change the MaxForce(maximum acceleration) and Responsiveness(Maximum jerk) and you can directly control the balls Velocity directly. Also, you can set the balls Friction to something high too that will make it roll

Sorry for very late response, I played the game though not quite what I’m looking for

How would I go about setting it up so the player can move around with LinearVelocity? I don’t really know how to do this

LinearVelocity is a constraint. Constraints need attachments.

So to start of you need an attachment. You don’t have to create a new one (If the balls network ownership is owned by the client that is) you can just take one of the attachments that are in the Body of the character e.g. RootRigAttachment

Then setup the LinearVelocity. You can create it via script then parent it to the ball. Keep a reference of the LinearVelocity. Make sure the Relative to is set to world as the attachment will be spinning around.

MaxForce is Maximum Acceleration. A higher value and the velocity will be quicker to reach the target.
Responsiveness is Maximum Jerk. It represents how fast the acceleration can be applied.

The rest is just the same as BodyVelocity. But instead with LinearVelocity.

LinearVelocity also provides some extra features that BodyVelocity does not. VelocityConstraintMode allows us to only apply forces in a specific direction. For example maybe we only want the Ball to move along the ground. For that you need to set it to Enum.VelocityConstraintMode.Plane

The Primary axis and Secondary axis are simply (1,0,0) and (0,0,1) note: you can see that we don’t want to apply the force in the Y Axis.

Then we can finally start rolling the ball. We can get the RelativeForward d ddairection of the Camera by doing this.

local Forward = CFrame.Camera.LookVector * Vector3.new(1,0,1) -- Flatten
Forward = Forward.Unit -- Normalize

Then you can map your Vector3 to the Vector2 plane ignoring the Y value.

Vector2.new(Vector3.X,Vector3.Z) -- Like this

Change the Plane velocity to that Vector and voila! It should move.

1 Like

Thank you! I will try this when I wake up

Again, sorry for late respone, this is what my ball script looks like following your suggestion:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local HRP = char:WaitForChild("HumanoidRootPart")
		local marble = Instance.new("Part")
		marble.Size = Vector3.new(8,8,8)
		marble.BrickColor = BrickColor.Random()
		marble.Transparency = .5
		marble.Shape = Enum.PartType.Ball
		marble.Parent = char
		marble.Material = Enum.Material.SmoothPlastic
		marble.Name = "Sphere"
		local Velocity = Instance.new("LinearVelocity")
		local Att = Instance.new("Attachment")
		Velocity.Parent = marble
		local Hum = char:WaitForChild("Humanoid")
		local Weld = Instance.new("Weld")
		Weld.Parent = marble
		Weld.Part0 = HRP
		Weld.Part1 = marble
		Att.Parent = marble
		Hum.PlatformStand = true

		local JumpScript = script.Effect:Clone()
		JumpScript.Disabled = false
		JumpScript.Parent = HRP.Parent
		marble.LinearVelocity.LineDirection = Vector3.new(0,0,0)

		local Forward = CFrame.Camera.LookVector * Vector3.new(1,0,1) -- Flatten
		Forward = Forward.Unit -- Normalize
		
		Velocity.LineVelocity =  100
		Velocity.LineDirection = Vector3.new(char.Humanoid.MoveDirection.z * 20,0,char.Humanoid.MoveDirection.x * 20)
		Velocity.MaxForce = 1000
		Velocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Plane 
		Velocity.Attachment0 = marble.Attachment
		Velocity.Responsiveness = 100
		Velocity.PrimaryTangentAxis = Vector3.new(2,0,0)
		Velocity.SecondaryTangentAxis = Vector3.new(0,0,2)
		Velocity.PlaneVelocity = Vector2.new(Vector3.X,Vector3.Z)
	
	end)
end)

It comes up with an error saying responsiveness isn’t a varaiable and even without it I can’t move my ball

Sorry my bad must have Got mixed up my constraint properties.

Just remove the line with responsiveness.

If you are using plane the you don’t really need the Line Velocity or Line Direction

It now says 'attempt to index nil with ‘look vector’
image

… I must have been sleeping when I wrote that reply lol…

Camera and Cframe are the wrong way round

there’s a red underline beneath camera, is it the same as currentcamera with (game.workspace.currentcamera) or no?

Yeah. I usually store it like this at the start of my scripts

local Camera = workspace.CurrentCamera

I’m still not moving sadly

Am I forgetting something

You may want to try and add more force to the ball.

Still nothing, I set it above 1m

Use TweenService or Body Movers