BodyPosition glitches through ground/walls

So in my game you have a rideable pet that flies in the air, the pet is moved with a body position. The problem is that when I move my pet straight into terrain / a part it will glitch through it, how can I prevent this? I lowered the pet speed as much as I can without making it boring but it hasn’t resolved the issue.

Try making the pet un collidable. As it won’t be affected by parts and shouldn’t have a problem getting stuck.

create a simple AI, Just to check if it is stuck and if it is teleport to you by changing some positions and messing with the CFrames.

@AlmostADemon @santingo_crack The problem isn’t that it’s getting stuck but that it can go through the ground, it shouldn’t be able to glitch right through it, but be kept in. Sorry for not making that clear.

Is the player constantly in the same position normally in 3D space on the Y-axis? If so, you can prevent the Y-axis of the BodyPosition from going below a certain Y value by not allowing it to.

Or, depending on what the Player is touching, you can make sure it never goes below the Y value of that part plus a few studs for offset to prevent clipping.

I potentially have gotten something wrong, I might need more info to be of more help.

Thanks for the suggestion, but my map isn’t flat, so I can’t keep the player over a specific height.

Just had the idea of having the player get off the pet whenever it touches the ground, unless I get any ideas that work I’ll do that.

I don’t know why I forgot to mention this, my pet flies in the air, so pathfinding wouldn’t be an option

1 Like

Maybe make the y axis match the players head y axis at all times?

Why not try using Raycasting to detect when its near the ground since Raycast can detect Terrain.

2 Likes

Try this instead - this is actually a lot better.

Just make it not past a certain Y axis, Or to keep a distance between the player and the ground like 5 studs.