# [PLUGIN] IK Solver 2

Completed plugins, behaviors and effects.

### » Wed Jun 17, 2009 5:44 pm

[size=150:1gr1drhk]IK Solver 2[/size:1gr1drhk]:

Version: 2.0.1

[size=150:1gr1drhk]IK Solver 2[/size:1gr1drhk]

NOTE: I suggest reading the below description/documentation before use. There is also an example at the bottom.

What's IK? - IK is a method for making a chain of bones bend in the correct way to reach a specific point.

What does this plugin do? - This is a plugin that takes all of the fancy math out of solving 2-bone IK chains. It automatically rotates the bones to the correct angle to reach a specified control point. It also positions the second bone automatically to the end of the first.

How does it work? - Very simply. The plugin consists of only one action: Solve IK. This action takes a few parameters:

- Bone 1: This is the first bone in the chain.

- Bone 2: This is the second bone in the chain. It will be positioned to the end of the first bone.

- Relative distance: This is the relative distance from the end of the first bone where the second bone will be positioned. For example, a value of -5 would place it 5 pixels from the end of the first bone, while 5 will place it 5 pixels past the end of the first bone.

- Control Point: This object represents the point that the IK-chain is attempting to reach.

- Direction: This is the direction of the bend of the bones. With outward, the bend will point towards the right when the control point is below the first bone, while outward will point towards the left in the same circumstance(see the example for a better explanation).

This action must be called every frame. The objects picked are the same as object picking everywhere else.

Example(s)

IK Solver 2 - Example File

And that's about it. Be sure to leave your comments/questions. I'm calling this done for now, but if there's anything you want to see, let me know!

NOTE: I HIGHLY recommend upgrading to this version if you are already using the original. It fixes two major flaws with the original. The actions will have to be swapped out by hand due to incompatibility between the two versions.
Moderator
B
115
S
41
G
20
Posts: 1,586
Reputation: 19,196

### » Wed Jun 17, 2009 6:10 pm

Nice plugin

I know this is offtopic, but could you fix this problem with your HUE plugin before releasing it?

Basically if you try to use it in a family, and you select the "set hue" action, you can't set the hue.
B
2
S
2
G
5
Posts: 512
Reputation: 2,674

### » Thu Jun 18, 2009 12:59 am

Thanks, man.

[quote="SuperV":1r242dqd]I know this is offtopic, but could you fix this problem with your HUE plugin before releasing it?

Basically if you try to use it in a family, and you select the "set hue" action, you can't set the hue.[/quote:1r242dqd]

I'm willing to bet that's a problem in Construct. I'd check using another effect to make sure, then submit a bug report if it has the same problem.
Moderator
B
115
S
41
G
20
Posts: 1,586
Reputation: 19,196

### » Thu Nov 19, 2009 12:02 pm

I think I found what was causing that bug with the bones disappearing. It seems if you resize one of the bones and then pull the control point over where they connect, they disappear.
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211

### » Thu Nov 19, 2009 4:39 pm

Damn, I thought I had fixed that. It appears to be a division by zero error, so It should be pretty easy to fix.

Moderator
B
115
S
41
G
20
Posts: 1,586
Reputation: 19,196

### » Thu Nov 19, 2009 10:52 pm

I've got a fixed version of this plugin up now:

[size=150:1qrdb6mp]IK Solver 2[/size:1qrdb6mp]

[FIX] - Having the control point at the position of the first bone would make all of the bones disappear due to a division by zero error.
Moderator
B
115
S
41
G
20
Posts: 1,586
Reputation: 19,196

### » Fri Nov 20, 2009 1:31 am

Cool, thanks again lman.
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211

### » Mon Dec 28, 2009 11:27 pm

I have something else im not sure about. If you would take a look at the cap, and notice the gap between bones when you jump. The question is, is that supposed to happen, because of how I'm handling the control point, or is there something else going on?

[url:nrb89k4x]http://dl.dropbox.com/u/666516/iksolvercustomovement.cap[/url:nrb89k4x]

Thanks.

Edit:
It seems to happen on both axis's , even when I set the relative distance closer to each other.
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211

### » Tue Dec 29, 2009 12:06 am

This is because you have the "Solve IK" action before you position the first leg object. Since the second bone is positioned to the current position of the first bone, a gap will occur if the first bone is positioned after the IK action. Just place said action after the action where you set the position of the first bone and it works fine.
Moderator
B
115
S
41
G
20
Posts: 1,586
Reputation: 19,196

### » Tue Dec 29, 2009 12:24 am

Ahh, got it thanks!
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211

Next