Search code examples
unity-game-enginegame-developmentinverse-kinematicsskeletal-meshragdoll

How can I make a system to lock aim to different parts of body with IK?


I just had this idea and would like to learn how to implement, what I wanna do is, when I press a button character's aim and also IK for aim, like arm position or how he holds the weapon are adjusted to head, legs or body of NPC and shoots it. Different buttons for different part. How would I go about implementing that, I just need a little nodge to the right approach, thanks in advance


Solution

  • I'm going to assume what you mean is that you want to press a button and it "auto" aims at a body part

    Well the first step would be to find and aim at the desired npc. (Many ways of doing this but just getting the location and rotation, and shooting a ray on frame update. Then rotating the character towards the desired location.)

    The second thing I can really think of is the IK but that should run really easy. Just get the transform of the NPC your aiming at and set that to the NPCs head hitbox.