# R6 Procedural Foot Planting Animation / Inverse Kinematics

1. What do you want to achieve?
I wanna procedurally generate my walking animation

2. What is the issue?
It works ok when walking forward, but totally messes up when walking backwards, sideways, or at an angle.

https://streamable.com/m6fwmd
(Lerping not yet implemented)

1. What solutions have you tried so far?
• detecting foot planting
• offsetting foot target positions based off keyboard input
• other stuff

Here are some files if you’re interested in looking at the code:
R6 Footplanting.rbxm (9.1 KB)

Here are some resources I’ve been looking at:

Would appreciate help.
If you need me to provide any more details just ask.

5 Likes

I think you have a problem with your targets.

I came across this problem when I was making my project.War Of Worlds - Battle of Croyium - Roblox (Edit: Updated link: Procedural Animation - Roblox)

The solution I used was to only make my character walk forwards.

However, in your case you would need to calculate how far the foot is from the target and move it in towards the player. I will show you.

I am not very good at drawing or explaining things but here is the code you need tor calculating where to put the targets.

``````local restPosition = --Here you put the position for the leg on the rest position. I usually use a raycast down from an attachment to signal the rest position
local maxDistanceFromRestPosition = --Here you put the maximum distance that the leg will be from the rest position
local footPosition, movementDirection = nil,nil
while true do -- Any update method here will be better
footPosition = --Get the foot Position
movementDirection = --Get the unit vector for the direction of movement for the player
if (restPosition - footPosition).Magnitude > maxDistanceFromRestPosition then --If the foot is far from the rest position
local footOffset = --Get the offset of the foot from the target you can do this by making a CFrame:ToWorldPosition or by manually subtracting the values. You do not need the Y value
TweenPosition(foot,footPosition,targetPosition - footOffset)
-- Or TweenPosition(foot,footPosition,footPosition - (2 * footOffset))
-- Or TweenPosition(foot,footPosition,targetPosition + (movementDirection * maxDistanceFromRestPosition)
end
end
``````

This is not real code so it will not work as is so you have to “adapt it” to your own needs. The code is just a guidline of what you can do

In other words you need to update your targets position based on either the direction of movement of the player or by getting the offset of the foot and offset target from the player accordingly

6 Likes