How to do a walk cycle for footplanting?

I’ve basically done every other aspect of my game, and this is (mostly) the last thing I really need to do but I don’t really get how.
I know how to do inverse kinematics (thats actually pretty easy to me), I just am looking for how do I get the endpoint (or the planting location) for the footplanting?
I know what I need to do is use raycasting and character velocity and direction vectors and stuff in the process but I’m not really sure how I go about doing it.

examples of what I would like it achieve is follows;
mostly would like it look like how kolton did it
https://twitter.com/Dev_Kaye/status/1220106025472229377
i liked how the second one looked in this

What I do know is there will definetly be two variables, storing the position of each foot (so that while one foot is being updated, the other can remain in a constant position)

I know I’ll need to do something like follows:

local lastUpdate = 0
local leftLeg = true
local leftPos = v3()
local rightPos = v3()

game:GetService("RunService").RenderStepped:Connect(function(dt)
	local vel, speed = getVel() --non unit velocity
	local leftOrigin, rightOrigin = --define these
	if speed > 0 then
		if lastUpdate + delayOf < tick() then
			lastUpdate = tick()
			--not sure whether to put this if statement inside this if or outside
			if leftLeg then
				--do stuff with the left leg
			else
				--do stuff with the right leg
			end
		end
	else
		--set positions to an idle position
	end
	--update both legs based on leftpos and rightpos
end)

this was my attempt:

but it looks very trashy and not smooth at all :frowning:

this seems to be basically forbidden knowledge or something in the scripting community since i cannot find hardly any resources on this to help me

i have been stuck on this for like literally ages now so I would love if anyone could help me :heart:

3 Likes

This is what I have tried so far:

however it doesn’t look that clean:

The reason why nobody really offers any insight into this is because procedural animations are a messy subject and can effectively be replaced by ordinary ones using multiple states.

The only relevant example previously made that I could find would be this custom character by stravant.

2 Likes

Yeah, I agree procedural animations are very messy. However, even though they can be replaced by something using multiple states (like semi procedural animations) I have no idea how to animate so I would probably end up wasting more time learning how to perfect animating it rather than just programming it.

I did look at stravant’s method of footplanting, however I am not a fan of the module script type workflow, so at first I got confused at what was going on at first.
Even then, it seems maybe a little bit over complicated (not saying its bad, I’m just thinking maybe it could be done in a simpler way).

This is something I want to learn myself, so (and this is open to anyone to answer), would it be best to calculate the next position based on velocity * direction then lerp at a constant rate? Basically, calculate where the character is expected to be next and then using direction to calculate the position?
Then I saw this post (linked earlier) and saw they where doing the average of the two positions then based on the direction if the average would be behind in the next update it would update the leg furthest away?

1 Like

You’ll still end up having to animate everything except for the legs. What I’d do is combine standard animations with “half IK”, where the legs are animated through keyframes, but get placed higher if required.

That post shows the best way to get the most natural result, so go with it.

2 Likes

I came up with something, it’s not a perfect solution and it’s a little bit messy but after 9 rewrites it does what I want somewhat (hopefully this may help out anyone who’s doing footplanting / walk cycles / procedural walk animations).
Source code can be found here.
New place with better footplanting here
you can also look at the source code

9 Likes