1

I have a problem with inverse kinematic. I'm not able to move a tentacle and I don't know why. I implemented many simple skeletons and succeed, but in this case there must be something I'm missing. Hope you can help me!

Here you have a detailed explanation:

1.- This image displays the tentacle I want to move. *"Flup" is a MovieClip containing both the tentacle and the circle below. *The tentacle itself is another MovieClip (inside "Flup" as said before) *The tentacle owns an armature

image

I just want to create a simple movement to start so, in this case, I will only try to move the blue bone.

2.- Flup is a class, so I create an instance in one frame

import IllGame.enemy.boss.*;

stage.addEventListener(MouseEvent.CLICK,moveTentacle);

//Creation of the monster and insertion into stage
var flup:Flup=new Flup();
flup.x=300;
flup.y=200;
stage.addChild(flup);

//Moves the tentacle (in this case the blue bone)
//to the click point
function moveTentacle(e:MouseEvent):void{
   flup.moveArmature(mouseX,mouseY);
}

3.- Flup class, very simple at this moment

package IllGame.enemy.boss{
   import flash.display.MovieClip;

   public class Flup extends MovieClip{
      public function Flup(){

      }

      //Recives the coordinates of the click point
      //"TentacleOne" is the instance name of the tentacle
      public function moveArmature(x:Number,y:Number){
         this.tentacleOne.moves(x,y);
      }
   }
}

4.- Next, we have the tentacle class. This class is the father of every single tentacle Flup will have, so it's the father of "TentacleOne"

package IllGame.enemy.boss{
   import flash.geom.Point;
   import flash.display.MovieClip;
   import fl.ik.*;

   public class Tentacle extends MovieClip{

      //Variables needed for inverse quinematic
      private var armature:IKArmature;
      private var bone:IKBone;
      private var joint:IKJoint;
      private var point:Point;
      private var movement:IKMover;

      private var armatureName:String;
      private var bonesName:String;
      private var bonesNumber:int;

      public function Tentacle(armatureName:String,bonesName:String,bonesNumber:int){
         this.armatureName=armatureName;
         this.bonesName=bonesName;
         this.bonesNumber=bonesNumber;

         armature=IKManager.getArmatureByName(armatureName);
      }

      //This function is supposed to move the 7ยบ bone (the blue one)
      public function moves(x:Number,y:Number){
         bone=armature.getBoneByName(bonesName+"7");
         joint=bone.headJoint;
         movement=new IKMover(joint,joint.position);
         movement.moveTo(new Point(x,y));
      }
   }
}

5.- Finally, TentacleOne class, which only sends information to its father

package IllGame.enemy.boss
{
   public class FlupTentacleOne extends Tentacle{

      const NUM_BONES:int=7;

      public function FlupTentacleOne(){
         super("Armature_20","ikBoneName",NUM_BONES);
      }
   }
}

I'm sorry for the long post, but I'm really annoyed about this and have no clue where the problem is. Thanks to everyone that tries to help me.

PS: When I run this code, X and Y vars for the skeleton position are modified but visually the armature keeps static.

Chunky Chunk
  • 16,553
  • 15
  • 84
  • 162

0 Answers0