My crouch/prone behaving weirdly

In a game I’m working, the crouch/prone generally behaves like it should, but if one decides to crouch from a high height before they hit the ground, you start to be forced around whenever you move.

Here is it working fine. It seems to work just how I want it if you crouch while you standing on a surface and not jumping.

Now here it is with your character feeling as if you are forcefully being pushed around while trying to move. This gets triggered whenever you either attempt to crouch in the air or fall off a ledge while crouching.

I have no idea how to fix physics-related issues like this. I’ve tried to make it so you could only crouch if the humanoid’s floor material wasn’t air. But attempting to block the problem from occurring hasn’t helped.

Here is what I’m doing. When the character initiates a crouch, I disable the animate script and stop all currently playing AnimationTracks. I then enable the crouch_idle animation. If the player is moving, I also use crouch_move animation. I also use a temporary function that I :Connect() and :Disconnect() when the player is and/or isn’t crouching to detect if they’re moving or not so I can determine if the crouch/prone movement animation should be played. I also check if the movement animation is playing so I don’t overplay it.

Has anyone else had a similar situation like this and found a fix? This has created buggy gameplay during a testing session we had, and it’s the one thing I can’t find a fix for.

5 Likes

It might be of value if I could see your script, just to get an insight on how you made this.

But with that being said, I could attempt to offer several possible solutions to you:

One idea might be, use raycasting. Cast a ray from underneath the player’s humanoidrootpart far enough down so it’s able to detect a floor. If there isn’t a floor, then don’t allow the player to crouch.

Another idea could be, if the player’s jumping (as I noticed in the clip of the problem) don’t allow the player to crouch. Rather, wait for the player to finish jumping, and if they attempt to crouch, disable the ability to jump during that. This could potentially fix those physics problems.

This is pretty much all I got. Hope it helps! If you decide to post your script I could take a look at it and see how you’re going about doing it.

I was in a rush when making this. Sorry if it’s unreadable. The crouch and sprint are part of the same module, but I’ll just keep the crouch parts in.

Here: --ChuckXZlocal Util = require(script.Parent.Util)local Crouching = false - Pastebin.com

This could be a solution, when working with tools with lots of parts/unions in I found if you don’t set the custom physical properties of parts inside the tool to 0 or in general physical properties of parts welded to the character then the movement seems to pivot around a point that isn’t the character and makes it feel like you’re being pushed.

[EDIT] = I think it’s something to do with making parts “weightless” so physics doesn’t try and mess with them. But this is only really, from my experience, if you have something welded to the character.

I’ll try this when I get home from school tomorrow. I think you’re on to something since I do have some objects welded to the character.

Edit: I removed all the objects to my char and even took of my hats to see if weight was an issue, but it doesn’t seem to be. This is really starting to puzzle me.

I’ve experienced something similar:

https://i.gyazo.com/736f19d567b2f8ddd1afa2f8a7ccc17c.mp4

I believe the problems is caused from the Head, UpperTorso, LowerTorso and HumanoidRootPart colliding with the floor.

To solve the initial problem you could disable the collision for these parts on the client, like so:

repeat runService.Stepped:Wait()
	if player and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
		player.Character.HumanoidRootPart.CanCollide = false
		player.Character.UpperTorso.CanCollide = false
		--main.player.Character.LowerTorso.CanCollide = false
		player.Character.Head.CanCollide = false
	end
until animationStopped

This is quite a hacky method though and can lead to some more problems.

I’m looking into a more effective solution.

4 Likes

I found the issue thanks to your workaround.

Turns the animation was pushing itself into the ground. The only problem is that your method makes the char walk through walls. I’ll just adjust the animtion to put more level on ground, and let certain part(s) be cancollidable. Thank you.

2 Likes