I am using @EgoMoose’s Gravity Controller, and am trying to have it work with Sprinting and Double Jumping scripts.
The issue I am currently having, is that when I sprint up a wall and reach the top, the character keeps flying in the direction of the gravity, instead of adjusting to the new side or the ground below it.
I have tried adding lines the Controller script that make so if the player is freefalling for x seconds, the gravity will be changed to normal. However this leads me to another issue.
As you can see in the GIF below PlatformStand is being enabled in the script and used to control the gravity. I assume that it is supposed to always be on, but in order for me to add the double jump, I need the state to become Freefall for at least a second or two after jumping.
In the GIF you can see that PlatformStand is enabled until I jump, then it does not re-enable, unless I jump off of a wall, for example.
This is the section of the Script that I am using to try to control HumanoidStateType
Summary
function GravityController:OnJumpRequest()
if (not self.StateTracker.Jumped and self:IsGrounded(true)) then
local hrpVel = self.HRP.Velocity
self.HRP.Velocity = hrpVel + self.GravityUp*self.Humanoid.JumpPower*JUMPMODIFIER
self.StateTracker:RequestedJump()
self.GravityUp = UNIT_Y
self.Humanoid.PlatformStand = false
print("PlatformStand disabled")
print("Humanoid Freefalling")
repeat wait() until self.Humanoid:GetState(Enum.HumanoidStateType.Landed) or self.Humanoid:GetState(Enum.HumanoidStateType.Running)
print("Passed Landed check")
if self.Humanoid:GetState(Enum.HumanoidStateType.Freefall) or self.Humanoid:GetState(Enum.HumanoidStateType.Running) or self.Humanoid:GetState(Enum.HumanoidStateType.Landed) then
self.Humanoid.PlatformStand = true
print("PlatformStand Enabled")
end
end
end
First things first: the link you posted at the top is to a much older version of the controller so unless someone is expressly familiar w/ the controllers they won’t be able to help much w/ the link you provided. Here’s the correct one:
As for your actual problem, I don’t quite understand what you’re attempting to do? At first glance it looks to me that you want the player to fall back to normal gravity when they jump or run off a surface while defying gravity?
Thank you for clarifying the correct link to the controller that I am using. I have edited the post and changed the link.
As for my problem; I want the player to return to normal gravity whenever they jump. This isn’t a problem when they are on the ground as they are still in normal gravity, but when they are walking on the side of a surface they still get pulled towards it.
Whenever the player walks from one side of an object to another side, I want them to stay attached like how the Controller currently works. I only want the player to return to normal gravity when jumping while standing on the side of an object, and if they jump off of an object.
I am not entirely sure of how the controller works, but I believe the difference between the first GIF and the second GIF has to do with the parts thickness and the how the raycasting is used, as the controller was enabled for both.
Edit: When I say Jump I really mean Double Jump, so that is why I was trying to change HumanoidStateType within the script I included in the original post.
I made adjustments on line 119 so that when the user is falling or jumping their gravity up is set to the default.
Controller.GetGravityUp = function(self, oldGravityUp)
if Controller.StateTracker.State == "onRunning" then
return GetGravityUp(self, oldGravityUp)
else
return Vector3.new(0, 1, 0)
end
end
Controller.GetGravityUp = function(self, oldGravityUp)
if Controller.StateTracker.State == "onRunning" then
return GetGravityUp(self, oldGravityUp)
else
return Vector3.new(0, 1, 0)
end
end
Are these the adjustments that you made on line 119?
This is line 114 through line 134 of the Gravity Controller place you send.
Summary
local collider, gyro, vForce, floor = InitObjects(self)
floor.Touched:Connect(function() end)
collider.Touched:Connect(function() end)
self.Collider = collider
self.VForce = vForce
self.Gyro = gyro
self.Floor = floor
-- Attachment to parts
self.LastPart = workspace.Terrain
self.LastPartCFrame = IDENTITYCF
-- Gravity properties
self.GravityUp = UNIT_Y
self.Ignores = {self.Character}
function self.Camera.GetUpVector(this, oldUpVector)
return self.GravityUp
end
The GetGravityUp function isn’t until line 178 in the place you sent, and I made the adjustments you left above. However, did not notice a difference in gravity control.
Summary
Edit: I just read through your post about the Gravity Controller, and realized you said that it loses the ability to track HumanoidStateType, which is probably why I haven’t been able to get the Double Jump to work.
Ahhh okay thank you haha, the controller is working great now except for certain terrain in which it the player either falls of the side or floats on top.