How do I do Footplanting for Walking IK? (R6)

Hello everyone, or those who see this:

I have been looking at IK for a week and been trying to study how it works with walking. Sadly I cannot find anything useful for it. I’ve seen some useful posts that have working ones, but sadly they are either broken R15 ones (I need r6), ones that just give you a script and tell you to just “Look at it”, or ones that are overcomplicated.

I have a friend who said its not that hard, he made his own but he forgot how to do it (He moved on from luau to C#) and yes, IK is somewhat complicated but it doesn’t have to be that hard to make.

I’ve tried to also look into free models but all of them are broken or R15. I’ve been told that it has to do with Rays, and CFrame but I couldn’t really figure out how to put those 2 together with it.

If you can find anything like sources (Or if for some reason you can give me a step by step thing, that would be insane but… Pretty useful for me and A LOT of other people), that would be great.

-squaredsnow

You don’t necessarily need to use CFrame for IK. For example, FABRIK only uses vectors.

What’s FABRIK?

Also, I want to script it if that is a plugin or something

FABRIK is one method of achieving IK, fordward and backward reaching inverse kinematics.
(30) FABRIK (Inverse kinematics) - YouTube

Although, being honest you don’t exactly need IK for r6 since the r6 rig’s legs are just one part.
You could probably work out a bit of math, get a fixed point on the ground via raycasting ( where the player will plant their foot ) and then change the motor6d’s properties based off the position, leg length and humanoid hip-height ( can’t remember if that was the exact name )

2 Likes

Sorry, I should have elaborated what my goal is here:

I want to make leg movement for my character because I am making an FPS game with a few friends. So when you move around you have that kind of movement along with a leaning body.

Also: With raycasting, how do I raycast the bottom of the foot? Or am I just not really that good with Raycasts

Again, all can be done with some math, no need for IK, once you do get the foot-planting working, you can workout a co-efficient that affects how much the player’s body leans in the direction of the foot and again a bit of math for that.

And with raycasting, you can raycast in the direction that the player is moving (humanoid.MoveDirection) and you can also take the velocity into account, you apply an angle downward since you want to raycast to the ground, see where the player should plant their foot.

This very rough diagram shows what I mean.

2 Likes

So when doing raycasting:

Could I do some angles to get the raycast to aim down at an angle?

Well you could just offset the starting position by half of the leg’s height, since a Vector3 position starts at the center of a BasePart that should offset it to just about the bottom of the foot if you do it right.

RayCasting is fairly simple once you learn how it works and get some practice using it. There’s plenty of tutorials on that. Other than this I’m really no help, as I don’t work with RayCasting much!

2 Likes

Sort of yes, you will need to look into CFrames and vectors since you will need to convert that angle along with velocity etc to a vector direction as rays point in a vector3 direction ( sorry i’m bad at explaining this ) look more into the maths of this and it should all come together.

Some methods you’ll use are CFrame:ToObjectSpace() and CFrame.Angles() for example

2 Likes

Not sure how I’m going to use velocity with that…

But so far, all I know is that:

I can get the movement direction and create a raycast, then use angles or whatever you use in CFrame for that to set the foots position there, but I am still unsure about how to get the foot to still somewhat connect to the body or just make the foot move in general for that.

Why would you ever need to use CFrames for angles using vectors?

If you’re only changing the Motor6d.C0 property then the leg will always remain attached to the player’s body.

You’ll be using velocity to influence that angle ‘theta’ as shown in the diagram, obviously if the player is moving slower, they may take smaller steps and bigger steps for faster movements, so the point of contact will have to be further out / closer to the player ( that means the angle will either have to be greater or smaller )

I probably didn’t explain it too well but what i’m trying to say is, you have that angle theta, that influences how close / far out the point of contact is. and raycast takes a vector3 for it’s direction parameter. You would need to use some of the CFrame methods to convert the angle and move direction into a direction for the raycast if that makes sense

1 Like

R6 footplanting by x_o, it’s open sourced
https://www.roblox.com/games/367789063/foot-planting-for-everyone111

4 Likes

Does it explain what it does? I want to learn about it more than just CTRL C + V

it doesn’t explain what it does, you can read the code to see what it does,
the code is old so expect some lag when using it on more than 5 rigs/characters

Max server size is 30… Could I somehow make some sort of cleanup system?

Yes, you can optimize the code by replacing deprecated functions, except :FindPartOnRay.
When a rig spawns, a local script uses a module to add them to a table with cframe stuff (ex: LeftHipC0Cache) and a RunService.Heartbeat connection, you can use :BindTheRenderStep() for more control but will be complicated to Un Bind them. After the rig dies, the RunService connection gets disconnected/unbinded so there won’t be a problems with memory. Maid is really perfect for something like this, even OOP (Object Oriented Programming)

1 Like

hey how’s the ik control learning going? I’m kinda stuck just like u were 2 years ago…