#Unity 2d - Moving IK Effector position

1 messages · Page 1 of 1 (latest)

tame rune
#

Hey guys. I have this 2d character in which I use IK to do animations. Im trying to make the character's hand move with the gun (the gun rotates with the mouse position). But whenever I move the IK Effector transform position from code, my char hands go crazy, rotating randomly. I'm using CCD Solver btw, tested with Contrain rotation on and off..
I implemented by doing this:

  • My weapon has a script with makes it rotates with mouse position
  • whenever it rotates, i get the weapon spriteRenderer.sprite.pivot position (which is set to where the hand should be)
  • set rightArmSolver.GetChain(0).effector.position = weaponSprite.transform.position or pivot.position;
scarlet oyster
#

Sounds like some sort of conflict. Do you have animation clips running at the same time that control some of the same things using key frames? Or do you use multiple solvers to control the same thing?

#

I have previously used a limb solver for animations (ie controlled by animator) when no weapon/equipment is used and then a CCD which is controlled by code only to aim at the mouse. Make sure to change the weights towards the "code controlled" solver and that it's in the IK manager after the limb one.

scarlet oyster
#

Did you make it work @tame rune?

tame rune
#

Hey, sorry I didnt see this. I'm going to test and let you know 🙂 thanks!