Custom Character Controller Help

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.

Here is a quick GIF of what I am talking about:

Summary

https://gyazo.com/84e33c9cae3fb1155b0178832b138f3a

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.

Summary

https://gyazo.com/7d0475591785bbed2085e111eda2f3e5

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
1 Like

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?

Could you try explaining again?

1 Like

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.

Instead of this:
https://gyazo.com/06e2373bacebd4fe6bdb40790e12b17f

I would like it to be something like this for the top of an object:
https://gyazo.com/feabdd4b301f2c582a3d3f3d261288dc

And like this for the side:
https://gyazo.com/545c7ad52ceb358208f9e02b825040c7

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.

Ah the easiest way to do that is through the GetGravityUp Method. For example in this place:

https://www.roblox.com/games/4597506405/Gravity-Controller

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
1 Like
Summary
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

image

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.

The “HumanoidStateType” is always on PlatformStanding
https://gyazo.com/b9b26e356cdd2c7e19df67c87f50d1f0

The changes i made were under the localscript that calls the module, not the module itself.

Also, yes you can’t use standard state tracking w/ this controller

2 Likes

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.

https://gyazo.com/06c4163d05c4d85fa7e143b946113fda
https://gyazo.com/1e7e10c85399da9d1722c5d4c801426b

It only seems to be a problem with flat terrain, as I am still able to walk on Rocky, edgy terrain just fine.

https://gyazo.com/5d73bf45409f0631d34881e7c9c564e4