Player walking around sphere

In my game, I want players to be able to walk around spheres like the sphere is a planet.

image

I have been messing with CFrames, velocities, and very confusing math trying to get this to work out and I’ve been recommended a character controller. However, I don’t know what that is or how to make one

Here are 2 posts which I’ve looked at, neither one seems to solve my issue:

Please note that there will be trees and buildings on the planet which I don’t want the player to walk on, so a wall stick module will not work. EgoMoose’s module seems to be buggy/broken at the moment, so that will not work either

This is quite complicated so you should break it into parts. I would start with making a system where you can “drive” a part around a sphere’s surface. The part will have a facing direction and position (euclidean) on the sphere. I would NOT recommend trying to represent this position as lat/lon, doing that will vastly complicate the math. When you try to move on the sphere, you should move in the facing direction while compensating for the curve away; this means moving forward is identical to rotating around an axis that passes through the sphere’s center and whose direction is the cross product of the facing direction and position. The “up” axis will always be the position minus the center of the sphere, and turning the character causes rotation around this up.

A major concern with this system, if the spheres are small, is stability. That is it should not be possible to build up energy infinitely. Otherwise you could get quite bouncy or wiggly physics. You can correct this by adjusting all movement based on potential energy. If you move along the surface, your new position must have the same height as the old position.

You need to make your own character controller. Rotating the model with the surface is not hard, but making it player controlled is. No way to achieve this with Humanoids.

I’ve already made a system where the player will be rotated correctly, it’s making them actually stick to the ground that’s an issue. I’ve disabled gravity for players by using velocities, but then the player isn’t able to jump.

Got it, I’m still a little confused on what a character controller is or if there’s a specific way I should go about making a new character controller (via a plugin, module script, or some sort of premade system roblox has to offer) or if I should script it myself.

The issue I’m having even with a character controller is movement. What I’m doing using a remote event to tell the server whenever a player has W, A, S, D, or jump pressed and making their new character mimic the appropriate movements. However, there’s a small delay between firing a remote event and the server receiving that remote event. That delay makes the movement feel very slow and slugish. Is there a better way to do that? Am I making this the right way?

[ID HIGHLY RECOMMEND MAKING YOUR OWN AND NOT USING A PREMADE CONTROLLER.]

By character controller i meant deleting the humanoid and replacing it with an animation controller. Use that to play animations for the character.

Now since youve removed the humanoid youve lost roblox controls - so use physics mover constraints inside the player to move it from the client. You dont need to send a remote for movement as physics constraints replicate automatically.

You would like to use a linear velocity for walking, a bodygyro for turning and rotating around sphere and a vector force for jumps.

1 Like

Got it. This seems fairly complicated, so I’ll work on it for a while and let you know how it goes once I’ve made some more progress

Thank you for the help

I just got the BodyGyro set up, however the player seems to be spinning around a bit. I’ve tried increasing the friction and FrictionWeight in custom physical properties, however this didn’t change much

Here are the properties for the BodyGyro (while in game) if it helps:

I forgot to add my code, here it is:

local HRP = script.Parent.Parent
local BodyGyro = script.Parent
local Ground = workspace:WaitForChild("Ground")

while task.wait() do
	BodyGyro.CFrame = CFrame.lookAt(HRP.Position, Ground.Position) * CFrame.Angles(math.rad(90), 0, 0)
end
1 Like

Turn up the bodygyros maxforce on the Y axis.

I did this, and now the player only wants to be looking towards the center of the planet. It’s not possible for me to rotate them so that they’re facing away from the center, the BodyGyro always pulls that back around and makes them face the center of the planet

That’s the main reason why I had the max force set to 0 on the y axis, but it does eliminate the rotation that was happening beforehand

Nevermind, I’ve just fixed this issue by changing the 2nd number in CFrame.Angles to determine where I want the player to be facing. This is giving me issues while turning though because I had to turn on the “CanCollide” option for the player’s legs, which causes the character to move places when rotating

Id recommend turning off legs collisions and use a ball part aligned with the tip of the legs for staying on the ground. That will also retain the roblox behavior of automatically going above small steps. Or you could raycast and use some sort of body position or vector force.