Jump to content

Bone rotation


Rick
 Share

Recommended Posts

When my character is strafing and moving I want to rotate the hip bone by 45 degrees and the spine bone 15 degrees. So I find these bones and after the correct animation is played I do the rotation but the bones never rotate. It looks to me that the animation is overriding my bone rotation. How can I do this manual bone rotation while still playing animations?

Link to comment
Share on other sites

I must be doing something wrong then. Here is the chunk of code I have. The idea is if I'm running forward and strafing, to rotate the hips.

 

if self.moveDir == self.dir.Forward then
   if self.shooting == true then
       self.animMgr:SetAnimationSequence(self.seq.RunShoot, .5, 100)
       self.animMgr:SetAnimationSequence(self.seq.ShootStand, 3, 0, self.spine)
   else
       self.animMgr:SetAnimationSequence(self.seq.Run, .5, 100)
   end

   -- this might not be needed but it rotates hips when moving diagonally
   if self.strafeDir == self.dir.Left then
       self.hips:SetRotation(Vec3(0, -45, 0), false)
   elseif self.strafeDir == self.dir.Right then
       self.hips:SetRotation(Vec3(0, 45, 0), false)
   end
end

Link to comment
Share on other sites

Making a new post because if I edit the above the stupid code formatting goes away and I'm not indenting it again :)

 

If I comment out the animation lines then the lower body does rotate. So I'm taking the assumption it's not rotating because of the animation.

Link to comment
Share on other sites

Although I'm using c++, my code looks very similar to yours:

 

__super::UpdateAnimation(this);

Leadwerks::Entity* ent = model->FindChild("Bip01_Spine1");
if (ent)
{
  ent->SetRotation(Vec3(0,0,rotation.x), false);
}

 

I can't spot anything wrong within your code, maybe this is something lua specific.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...