I’m trying to make a gravity flip system which flips your gravity. But I’m very confused and I need help. The character uses “VectorForce” and “AlignOrientation” to actually flip the gravity, but it doesn’t let me move and jump. Also I don’t want to use @EgoMoose’s gravity controller because its to complex for me.
local script:
local Player = game.Players.LocalPlayer
local humanoid = Player.Character.Humanoid
humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Flying, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.PlatformStanding, false)
coroutine.wrap(function()
while task.wait(0.1) do
local Height = (0.5 * Player.Character.HumanoidRootPart.Size.Y) + humanoid.HipHeight
local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Vector3.new(0, 1, 0) * (Height + -.1))
local Hit, Point, Normal, Material = workspace:FindPartOnRay(ray, Player.Character)
if Material then
print(Material) -- enum
end
end
end)()
I’m half asleep right now but here is an example of how to set up a gravity flip and custom jump
local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Disable default states that will interfere
humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- ... disable other states as you did before ...
-- Setup VectorForce
local vectorForce = Instance.new("VectorForce")
vectorForce.Force = Vector3.new(0, humanoidRootPart.AssemblyMass * workspace.Gravity, 0)
vectorForce.ApplyAtCenterOfMass = true
vectorForce.Attachment0 = humanoidRootPart:FindFirstChild("BodyForceAttachment") or Instance.new("Attachment", humanoidRootPart)
vectorForce.Parent = humanoidRootPart
-- Setup AlignOrientation
local alignOrientation = Instance.new("AlignOrientation")
alignOrientation.Attachment0 = humanoidRootPart:FindFirstChild("BodyGyroAttachment") or Instance.new("Attachment", humanoidRootPart)
alignOrientation.Attachment1 = --[[ Set up an attachment or part in the world to align to ]]
alignOrientation.Parent = humanoidRootPart
-- Custom jump function
local function customJump()
-- Calculate the jump force required
local jumpForceMagnitude = humanoid.JumpPower * humanoidRootPart.AssemblyMass
-- Apply the force upwards relative to the character's orientation
vectorForce.Force = humanoidRootPart.CFrame:VectorToWorldSpace(Vector3.new(0, jumpForceMagnitude, 0))
-- Reset the force back to gravity after a short delay
task.delay(0.1, function()
vectorForce.Force = Vector3.new(0, humanoidRootPart.AssemblyMass * workspace.Gravity, 0)
end)
end
-- Bind the jump action to the space key
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, isProcessed)
if not isProcessed and input.KeyCode == Enum.KeyCode.Space then
customJump()
end
end)
local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Disable default states that will interfere
humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- ... disable other states as you did before ...
-- Setup VectorForce
local vectorForce = Instance.new("VectorForce")
vectorForce.Force = Vector3.new(0, humanoidRootPart.AssemblyMass * workspace.Gravity, 0)
vectorForce.ApplyAtCenterOfMass = true
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.World
vectorForce.Attachment0 = humanoidRootPart:FindFirstChild("BodyForceAttachment") or Instance.new("Attachment", humanoidRootPart)
vectorForce.Parent = humanoidRootPart
-- Setup AlignOrientation
local alignOrientation = Instance.new("AlignOrientation")
alignOrientation.Attachment0 = humanoidRootPart:FindFirstChild("BodyGyroAttachment") or Instance.new("Attachment", humanoidRootPart)
alignOrientation.MaxTorque = 1000000
alignOrientation.Attachment1 = workspace.Baseplate.grav --[[ Set up an attachment or part in the world to align to ]]
alignOrientation.Parent = humanoidRootPart
-- Custom jump function
local function customJump()
-- Calculate the jump force required
local jumpForceMagnitude = humanoid.JumpPower * humanoidRootPart.AssemblyMass
-- Apply the force upwards relative to the character's orientation
vectorForce.Force = humanoidRootPart.CFrame:VectorToWorldSpace(Vector3.new(0, jumpForceMagnitude, 0))
-- Reset the force back to gravity after a short delay
task.delay(0.1, function()
vectorForce.Force = Vector3.new(0, humanoidRootPart.AssemblyMass * workspace.Gravity, 0)
end)
end
-- Bind the jump action to the space key
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, isProcessed)
if not isProcessed and input.KeyCode == Enum.KeyCode.Space then
customJump()
end
end)