For the past couple of weeks, I’ve been trying to figure out how to make my own custom gravity system for characters. It’s for a space game I’ve been planning to make. So far, I haven’t been able to make any progress, and I don’t even know where to start. I know there is a pre-made module called GravityController that some people use, but I don’t want to use other people’s modules for a mechanic so important in my game. Another thing I’m trying to accomplish is having the players move with their spaceships. For example, even if the ship you are on is moving, you should be able to get up and walk around normally no matter how much the ship moves or turns. I’m completely stuck, and any help would be massively appreciated.
I believe VectorForce (video) is used for gravity, and then maybe apply another VectorForce for countering the speed. I’m not an expert here lol.
For gravitational force, Google’s search labs show this
Alright, Ill look into that, thanks!
I tried looking through the physical constraints of the player while loaded, and didn’t find any force instances in the character.
workspace.Gravity will apply gravity outside of a constraint. I would recommend setting it to 0 for your game.
Oh definitely, I’ll be handling “world” gravity separately.
These are the basic methods I’m hoping to accomplish:
local GravityController = {}
GravityController.__index = GravityController
function GravityController.new(player)
local self = setmetatable({}, GravityController)
return self
end
function GravityController:SetGravityDirection()
end
function GravityController:SetGravityToPart()
end
function GravityController:SetGravityToPosition()
end
return GravityController
- A constructor to add the player to the gravity system. (called every time the player joins or has their character reset)
- A method to set the player’s gravity based on direction (not relative to any part)
- A method to set the player’s gravity based on a part (gravity direction constantly updates to be the down vector of the part, and player moves with the part)
- A method to set the player’s gravity based on a position (gravity direction constantly updates to be toward the given position, for planets)
I found a gravity system a long time ago.
After trying to modify it, I realized I had a lot to learn.
It may have things that can help you find your way:
WalkOnWallks.rbxl (192.8 KB)
This helps a greatly, thank you. I’ll study it alongside the gravity controller made by egomoose.
take a look at this.