How to make a Tripod Advanced Ai system

I just wanna know how to make a Tripod AI… I know that it need to use Inverse Kinematics…

Somthing like this:
War of the Worlds | Dev diary - Early look at the new procedural animations (youtube.com)
War of the Worlds | Dev diary - New procedural animations - (youtube.com)
War of the Worlds | Uberpod Testing (youtube.com)

I dont know where to start and how to even make or use the IK controller…

I hope you guys can help me!

1 Like

Use the documentation and test out ik control in studio.

Then for doing it procedurally follow this unity tutorial.

2 Likes

Read some of the documentation and found a good video that explains the IK Controller…

Heres a Video of the system!


This is what i have:

Red = The part to look at
Yellow = The Target Position of the Head
Blue = Joint, Knee and Foot parts
Green = Silly head


The Handler:

local RunService = game:GetService("RunService")

local legHeight = 18 
local HeightHead = 20 

local ray = RaycastParams.new()
local overlap = OverlapParams.new()
overlap.FilterType = Enum.RaycastFilterType.Exclude
overlap.FilterDescendantsInstances = {script.Parent}
ray.FilterType = Enum.RaycastFilterType.Exclude
ray.FilterDescendantsInstances = {script.Parent}

local function ChangeHeadHeight()
	local Model = script.Parent
	local raycastResult = workspace:Raycast(Model.Head.Position, Vector3.new(0, -1000, 0), ray)
	if raycastResult then
		local terrainHeight = raycastResult.Position.Y
		local desiredHeadHeight = terrainHeight + HeightHead
		Model.Head.Position = Vector3.new(Model.Head.Position.X, desiredHeadHeight, Model.Head.Position.Z)
	end
	ChangeHeadHeight()
end
local function IKstep(origin,foot)
	local raycast = workspace:Raycast(origin,Vector3.new(0,-legHeight*2,0),ray)
	if raycast and not script.Parent:GetAttribute("Ragdoll") then
		local OriginalPosition = foot.Position
		local TargetPosition = raycast.Position+Vector3.new(0,0.5,0)
		local distance = (TargetPosition-OriginalPosition).Magnitude
		local PivotCFrame = CFrame.new(TargetPosition,OriginalPosition)*CFrame.new(0,0,-distance/2)
		
		if distance > 1 then
			for i = 1,10 do
				foot.Position = PivotCFrame*CFrame.new(0,0,-distance/2).Position
				PivotCFrame*=CFrame.Angles(math.rad(18),0,0)
				task.wait()
			end
			
			foot.Position = TargetPosition
		end
	end
end
RunService.Heartbeat:Connect(function()
	script.Parent.Head.AlignOrientation.CFrame = CFrame.new(script.Parent.Head.Position, script.Parent.Debug.LookAt.Position)
	script.Parent.LeftJoint.CFrame = script.Parent.Head.LeftAttachment.WorldCFrame
	script.Parent.LeftKnee.Position = script.Parent.LeftFoot.Position+(script.Parent.LeftJoint.Position-script.Parent.LeftFoot.Position)/2
	local distance = math.max(1,legHeight-(script.Parent.LeftJoint.Position-script.Parent.LeftFoot.Position).Magnitude)
	script.Parent.LeftKnee.CFrame = CFrame.new(script.Parent.LeftKnee.Position,Vector3.new(script.Parent.Head.Position.X,script.Parent.LeftKnee.Position.Y,script.Parent.Head.Position.Z))*CFrame.new(0,0,distance) -- the bend of the legs

	script.Parent.RightJoint.CFrame = script.Parent.Head.RightAttachment.WorldCFrame
	script.Parent.RightKnee.Position = script.Parent.RightFoot.Position+(script.Parent.RightJoint.Position-script.Parent.RightFoot.Position)/2
	local distance = math.max(1,legHeight-(script.Parent.RightJoint.Position-script.Parent.RightFoot.Position).Magnitude)
	script.Parent.RightKnee.CFrame = CFrame.new(script.Parent.RightKnee.Position,Vector3.new(script.Parent.Head.Position.X,script.Parent.RightKnee.Position.Y,script.Parent.Head.Position.Z))*CFrame.new(0,0,distance)

	script.Parent.MiddleJoint.CFrame = script.Parent.Head.MiddleAttachment.WorldCFrame
	script.Parent.MiddleKnee.Position = script.Parent.MiddleFoot.Position+(script.Parent.MiddleJoint.Position-script.Parent.MiddleFoot.Position)/2
	local distance = math.max(1,legHeight-(script.Parent.MiddleJoint.Position-script.Parent.MiddleFoot.Position).Magnitude)
	script.Parent.MiddleKnee.CFrame = CFrame.new(script.Parent.MiddleKnee.Position,Vector3.new(script.Parent.Head.Position.X,script.Parent.MiddleKnee.Position.Y,script.Parent.Head.Position.Z))*CFrame.new(0,0,distance)
end)

while task.wait() do
	IKstep(script.Parent.LeftJoint.Position,script.Parent.LeftFoot)
	IKstep(script.Parent.RightJoint.Position,script.Parent.RightFoot)
	IKstep(script.Parent.MiddleJoint.Position,script.Parent.MiddleFoot)
end

Now how would i make an advanced ai system…

1 Like