# What technique would I use to animate a 2D curling tentacle?

I have played around in Cocos2D-X and I think I understand the limitations of sprite-based animation fairly well.

I want to have a game with some characters curling and extending a tentacle which varies in length and amount of curl depending on the terrain.

Maybe imagine a sloth swinging from a tree but with arms that stretch at times (Gumby character?).

Is there a name for such a technique?

Would this be a variant on Animating Bezier Curves as seen in Jason Davies's example or discussed in this blog on tweening control points?

I'm a very experienced polyglot programmer but relatively naive in games and graphics.

• You did appear to be trying to avoid it, but you were still asking "which technology to use". Those types of questions aren't on topic here, and ultimately dilutes this question. Commented May 18, 2016 at 15:47
• Note that your edit weakened my question because I don't CARE which technology I use - I want to know how to do this technique in SOME technology. How on earth do I ask that kind of question without someone diving in and "helping" me? Commented May 23, 2016 at 12:38
• I disagree, removing your questions about which technology you can use opens this up to have answers provided at a higher level. Since you're more interested in the technique and not the implementation, it's best to avoid asking about a specific technology. Commented May 23, 2016 at 13:28

Since you're referring to s 2D sprite based game, I would use sprite segments to create the tentacle.

Each section inherits the rotation angle from the parent and adds a bit of angle of it's own. Each section n is calculated as

section[n].position.X=section[n-1].position.X+cos(section[n-1].angle)*sectionlength;
section[n].position.Y=section[n-1].position.Y+sin(section[n-1].angle)*sectionlength;
section[n].angle=section[n-1].angle+extraangle;


Now by altering the angle for each section you can make the tentacle curl. Add sections or stretch the section length (scale the sprites) you can vary the lentgh of the tentacle.

• Would that still provide a smooth shape looking like one continuous body? I'm going for really smooth stretching and curling animation as a core part of the game play. (It works nicely on my paper sketched "flipbook"!) Commented May 18, 2016 at 16:36
• Depends on the number of sections, but yes. There are some examples in Spine that use the technique. You can make it flow much like the tail of the 1st boss in R-Type. Commented May 18, 2016 at 16:41
• Great series on the topic Commented May 19, 2016 at 18:03
• Indeed the part where forward kinematics is explained shows a simple 3 segment tentacle, using the technique. Thanks for adding it. Commented May 19, 2016 at 18:33
• I was originally leaving the choice of technology open but some "well-meaning editor" took that out because that would make it a question of "which technology to use". Sigh. So, I'm NOT wedded to using sprites. Regardless, Spine (from esotericsoftware.com) does look very cool. Commented May 23, 2016 at 12:37

It seems that Soft Body Physics comes close, particularly as seen in Skeel Lee's work with goal and surface springs and Pressurized Soft Body with Local Deformation.

Note I found the above following the answers on Dynamic body implementation

Based on @felsir's answer, yes it looks like Spine is probably the answer. A graphical modelling tool, it includes exports to a number of game engines.

Relevant technologies it includes, which gives me the bibliography I was searching for, are:

• Free-form deformation so a model defined in a mesh can be distorted, combined with Weights (aka Skinning) to attach images to the mesh.
• Inverse Kinematics to help work backwards from the range of motion desired, to define joints needed