Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a Minecraft-style sneak system?

Asked by 4 years ago

How would I create a system that prevents players from falling/walking off edges. (I'm not talking about a system that lifts player back up after they fall, I'm talking about preventing from falling, much like the "Sneak" function in Minecraft) So far the only idea I've had is constantly raycasting to see if there is a part under the player, but how would I prevent them from walking off once the raycast returns nil?

1 answer

Log in to vote
0
Answered by 4 years ago

Use a renderstepped (fires between the physics engine and the frame update) to test if the player has a negative Y velocity. Once they do, multiply both the X and Z velocity by -1, and set the Y to 0, so the illegal movement they made gets cancelled out.

The method above is how minecraft itself does it, although it works far better with their movement system since it utilizes movement acceleration where roblox seems to just have a constant move speed.

This sound like it would work with some tweaking, lmk how it goes. Good luck.

Ad

Answer this question