I would like to create centrifugal gravity for a randomly-generated space station survival game made by my friend avasyz called “Seraphyra,” inspired by Doors, Alien: Isolation, Ultrakill, Cyberpunk, and more. I have tried egomoose’s gravity controller script, but it changed the gravity on every part and the scripting was barely understandable, so I did not know where and how to effectively alter the script.
Hey,
Hope you’re doing well.
Would you be able to provide the script that detects the change with a reference to the object (the part) that it obtains the attributes from? I did see you mention that you don’t know which script controls it, so if you’re unable to locate it - then just send the appropriate scripts through.
here are the script models I used:
replicated storage scripts: (I tried editing the “GravityController” module)
starter character scripts:
starter player scripts:
The GravityController script has the collider part and is involved in changing the gravity.
I think you’re best option is to add a vectorforce to the parts of which gravity you want to change on the y axis.
I think this is the function EgoMoose uses to get the colliding parts. It is found in the GravityController module.
function GravityController:IsGrounded(isJumpCheck)
if (not isJumpCheck) then
local parts = self.Floor:GetTouchingParts()
for _, part in next, parts do
if (not part:IsDescendantOf(self.Character)) then
return true
end
end
else
if (self.StateTracker.Jumped) then
return false
end
-- 1. check we are touching something with the collider
local valid = {}
local parts = self.Collider:GetTouchingParts()
for _, part in next, parts do
if (not part:IsDescendantOf(self.Character)) then
table.insert(valid, part)
end
end
if (#valid > 0) then
-- 2. do a decently long downwards raycast
local max = math.cos(self.Humanoid.MaxSlopeAngle)
local ray = Ray.new(self.Collider.Position, -10 * self.GravityUp)
local hit, pos, normal = workspace:FindPartOnRayWithWhitelist(ray, valid, true)
-- 3. use slope to decide on jump
if (hit and max <= self.GravityUp:Dot(normal)) then
return true
end
end
end
return false
end