A simple Inverse Kinematics library for LÖVE
Put the IK.lua file in your project folder and require it. You also need to put the vector.lua file in your project folder and require it.
local IK = require 'IK'local IK = require 'IK'
local ik
function love.load()
ik = IK()
for i = 1, 20 do
ik:addSegment(20)
end
ik:setFixedPoint(love.graphics.getWidth() / 2, love.graphics.getHeight())
ik:setTarget(love.mouse.getPosition())
ik.debug = true
end
function love.update(dt)
ik:setTarget(love.mouse.getPosition())
ik:update()
end
function love.draw()
ik:draw()
endCreates a new IK object.
A boolean value that determines whether the IK object is drawn or not.
Adds a segment to the IK object.
Sets the fixed point of the IK object.
Sets the target of the IK object.
Updates the IK object.
Returns the medium point of the Segment object.
Pulls the Segment object to the given point.
Draws the IK object.