2

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.

Gnemlock
  • 5,263
  • 5
  • 28
  • 58
Andy Dent
  • 123
  • 4
  • 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. – House May 18 '16 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? – Andy Dent May 23 '16 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. – House May 23 '16 at 13:28

3 Answers3

3

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.

Felsir
  • 4,067
  • 2
  • 16
  • 32
  • 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"!) – Andy Dent May 18 '16 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. – Felsir May 18 '16 at 16:41
  • 1
  • Indeed the part where forward kinematics is explained shows a simple 3 segment tentacle, using the technique. Thanks for adding it. – Felsir May 19 '16 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 http://esotericsoftware.com/) does look very cool. – Andy Dent May 23 '16 at 12:37
  • Even without the sprite requirement, I would go the segment route. A spline looks very nice on paper, but you will probably still end up using line segements to draw them. Als controlling each segment will give you a much better control over the tentacle movement than using the spline control points. Unless your purpose is generating terrain (like used in TinyWings), where you generate it once. – Felsir May 23 '16 at 12:59
0

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

Andy Dent
  • 123
  • 4
0

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
Andy Dent
  • 123
  • 4