• Unity
  • Move IK target around player with gamepad joystick

  • Изменено
Related Discussions
...

Hey all,

I apologize if I'm missing something posted here but I did do a search for this topic and didn't see this listed.

Does anyone know of a tutorial to move an IK target around a player using a gamepad joystick?

FIX:
I wasn't able to figure out how to manipulate the imported IK target itself, but I did make my own, easy enough. The code for that can be found below for anyone else that's a beginner like myself:

void Update()
   {
       if (Player.isRight)
       {
           thisTransform.localPosition = new Vector3(0 + Player.Horizontal * 4, 2 + Player.Vertical * 2, 0);
       }

   else
   {
       thisTransform.localPosition = new Vector3(0 - Player.Horizontal * 4, 2 + PlayerVertical * 2, 0);
   }
   }

The IK point must be a child of the Player object for this to work.

Glad you could resolve the problem yourself.

For reference, you can have a look at Spineboy's setup and code in the Spine Examples/Getting Started/4 Object Oriented Sample scene that is included in the spine-unity package. Here Spineboy aims and fires his gun at the mouse cursor position.