Foot IK for quadruped

Hello, everybody!
Recently i have started making a simple game, just for experience and i though - can i make a foot ik for the cat skeleton. I have seen a lot of IK tutorials on 2 bone inverse kinematics, but none for quadrupeds. I played a Boy-Kite demo and the animals in there had the IK but i have no idea how to do that. So if anybody could help me it would be great!

108074-deer.png

The ik system is gonna be exactly the same as if you do for a biped . Apply simple IK for all 4 legs and move down the chest and hip down accordingly through ray trace .

Do the animals in the Kite demo actually have quad-IK or did they just put the root bone in the center and rotate the root/capsule to match the slope of the ground? That still requires some math but not as much as IK on all 4 legs.

I don’t remember any rough terrain in the demo that would have required IK, just gently sloping hills covered in grass that would have hidden most misplaced feet.

Kite Demo use a calculated terrain angle value to control both an AimOffset node for pitch and roll of the animations and to rotate the skeletal mesh.
Now I don’t really understand how the terrain angle is calculated. It looks like it’s done with this code but can’t translate it in blueprint
:

	RequestedVelocity = Pawn->GetActorForwardVector() * ClampedSpeed;

	if (CharacterMovement->CurrentFloor.bBlockingHit)
	{
		FVector LocalNormal = Pawn->GetTransform().Inverse().TransformVector(CharacterMovement->CurrentFloor.HitResult.Normal);
		TerrainRotation.Pitch = -FMath::RadiansToDegrees(FMath::Atan(LocalNormal.X));
		TerrainRotation.Roll = -FMath::RadiansToDegrees(FMath::Atan(LocalNormal.Y));
	}
	else if (CharacterMovement->CachedProjectedNavMeshHitResult.bBlockingHit)
	{
		FVector LocalNormal = Pawn->GetTransform().Inverse().TransformVector(CharacterMovement->CachedProjectedNavMeshHitResult.Normal);
		TerrainRotation.Pitch = -FMath::RadiansToDegrees(FMath::Atan(LocalNormal.X));
		TerrainRotation.Roll = -FMath::RadiansToDegrees(FMath::Atan(LocalNormal.Y));
	}
	else
	{
		TerrainRotation = FRotator::ZeroRotator;
	}
	
	Super::ApplyCrowdAgentVelocity(RequestedVelocity, DestPathCorner, bTraversingLink, bIsNearEndOfPath);

You are better of using DragonIK from the marketplace and use that to get ik working quadrupeds instead of making it from scratch.

IK is way more accurate than Kite Demo code but way too expensive for lot of characters

This is what I get when trying to translate the Kite Demo code above but returned values are incorrect :