How do I stop this behaviour after the collision?

As you can see in this video, after the character collides with a wall, it kind of ragdolls? I want to stop this from happening. A friend told me I could use a BodyGyro, but I honestly have no clue as to how use it that way. Any ideas on how I can accomplish this?

Video: 2022-02-16 17-08-28

1 Like

Yeah a body gyro might help here. You might also be able to disable some of the humanoid states, like FallingDown, GettingUp, and Ragdoll.

For the BodyGyro, you can lock the orientation of the body so that it always has it’s top is facing up by creating a BodyGyro, putting it under a part (HumanoidRootPart) and setting the MaxTorque to Vector3.new(1,0,1)*1000000

1 Like

I will try to make that with the bodygyro and give feedback afterwards, thanks for responding!
Also, the Humanoid State while jumping is Flying, if I were to put it with the default one, some strange behavior happens.

Alright so I gave it a shot and, tought it isd always vertical now, it still makes the Character look at the Camera sometimes. This is the code I am using:

local function OnUpdate()
	local Character = LocalPlayer.Character
	if Character and Character:FindFirstChildOfClass("Humanoid") then
		local Gyro = Character.PrimaryPart:FindFirstChildOfClass("BodyGyro")
		if Gyro == nil then
			Gyro = Instance.new("BodyGyro")
			Gyro.MaxTorque = Vector3.new(1,0,1)*1000000
			Gyro.P = 1000
			Gyro.Parent = Character.PrimaryPart
		end

		local movementDirection = Left - Right
		local moveVector = Vector3.new(movementDirection, 0, 0)
		local currentPosition = Character.PrimaryPart.CFrame.Position
		if movementDirection ~= 0 then
			Character:SetPrimaryPartCFrame(CFrame.new(currentPosition, currentPosition + moveVector))
			Gyro.CFrame = CFrame.new(currentPosition, currentPosition + Vector3.new(Character.PrimaryPart.CFrame.LookVector.X, 0, 0))
		end
		Character.Humanoid:Move(moveVector, false)
	end
end

I know it may suck in regards to optimization, but I will try to improve it. How would I fix the problem at hand from here?

Video for reference on what is happening:

Edit: Though I realised the condition was in the wrong place, now I am being flung.

I don’t think your character is being flung any more than they would be just colliding with the terrain. You may want to implement code that keeps your character on the 2d plane and see how that works before trying to debug this further.