I’ve been trying to make gravity like CocoaWarrior’s Solar Conquest II but I don’t know how to make the gravity work for characters. I want to add enemy npcs so locally setting the gravity for a player isn’t an option plus I don’t want players network ownership affecting things it shouldn’t. Currently I’m applying a vector force downward from the character’s UpperTorso but it is wonky and jumping is weird. If you want me to give code for understanding I will, but I don’t think it will be of much help to the problem. So, how do I apply “gravity” to characters?
I’m not sure exactly what you’re looking for? You can adjust the global gravity rate in Workspace.Gravity
and you can change the CustomPhysicalProperties
in the arms/torso etc. to adjust each character’s individual weight.
My bad, I’m trying to make flat planets and make them have individual gravity so one planet would be 50 gravity and another would be 150 gravity.
Oh, got it. You could make a server script that
- Checks the distance of each player to the nearest planet
- If the player is within a certain distance of this planet, give the player the required gravity by changing their characer’s weight.
- Otherwise, make the character weightless to give the feeling of zero-gravity
I’m not sure if this is the most efficient solution but it would definitely work.
How would I change the characters weight?
Change the CustomPhysicalProperties
in the arms, torso, etc. This allows you to change the density, friction, and elasticity of each limb.
For example:
-- This will make each limb light and bouncy
local DENSITY = 0.3
local FRICTION = 0.1
local ELASTICITY = 1
local FRICTION_WEIGHT = 1
local ELASTICITY_WEIGHT = 1
local newProperties = PhysicalProperties.new(DENSITY, FRICTION, ELASTICITY, FRICTION_WEIGHT, ELASTICITY_WEIGHT)
-- add all of the character limbs to the array below.
for _, limb in pairs({character.Head, character.UpperTorso, character.LowerTorso}) do
limb.CustomPhysicalProperties = newProperties
end
You can read more about CustomPhysicalProperties here
The property you’re really looking for is the Density which makes the part heavier or lighter.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.