Skip to content

Using Aim IK in Unity 2D | version 2.x

Ehsan edited this page Aug 14, 2022 · 1 revision

Aim-IK Wiki

How to use Aim-IK in Unity-2D?

Here are the following steps to using Aim-IK in Unity-2D:

  • At first, create a new project in Unity.
  • Add your Rigged 2D model (Or sprite).
  • Download Aim-IK DLL or Aim-IK Unity Package file.
    • If you download the Aim-IK.dll file, you should make a folder in your Unity Assets folder with the name Plugin. Then put Aim-IK.dll file to it.
  • But if you downloaded Aim-IK.unitypackage file, go to Unity. In the Assets folder, press right-click and then click on Import package > Custom Package.... Then choose Aim-IK.unitypackage and click on Import button.
  • Now, Aim-IK is ready to use!
  • Select your character.
  • Press Add Component. Follow Scripts > AimIK > Aim IK Behaviour 2D.
  • In the Aim IK Behaviour 2D script, you see some properties.
  • In the Target property, select the target object.
  • By enabling the Smooth Look At check-box, the character smooth looks at the target.
  • If you enable the Smooth Look At, you should set a value in Smooth Time property (The standard value of Smooth Time is between [0, 1]. By increasing it, the character looks at the target faster).
  • In the Head property, you see these options:
    • In the Part property, select the head rig (Or sprite).
    • Another property is Position Offset. You can use it to set the eye position offset to the head character.
    • The next property is Rotation Offset. You can use it to set the rotation offset to the head.
    • So if you want to limit the head rotation in the z axis between two Min and Max variables, you can use the Head Limit Rotation option (NOTE: If you want to limit the rotation, enable Active check-box).
  • OK, now press Run and you see the head of the character, looks at the target. Cool!
  • And the last property is Chest Parts. It's an array that you can choose other chest parts that you want to look at the target.
    • In the Part property, select part rig (Or sprite).
    • In the Position Offset property, set position offset to the part.
    • In the Rotation Offset property, set rotation offset to the part.
    • In the Limit Rotation property, limit the part rotation in the z axis between two Min and Max variables.

Using Head Gizmos 2D

Head Gizmos 2D using for draw eye line in the editor menu to show the aim direction.

  • For using Head Gizmos 2D, select the 2D character that you added Aim IK Behaviour 2D previously.
  • Click on Add Component. Follow Scripts > Head Gizmos 2D.
  • Now, the Head Gizmos 2D added successfully!
    • NOTE: You can't add Head Gizmos 2D without adding Aim IK Behaviour 2D.
  • In this script, you see some properties.
  • If you enable Show Head Line, the eye line showing in the editor menu.
  • In the Head Line Color, you can set the eye line color.

Using Part Gizmos 2D

Part Gizmos 2D using for draw chest line in the editor menu to show the aim direction.

  • For using Part Gizmos 2D, select the 2D character that you added Aim IK Behaviour 2D previously.
  • Click on Add Component. Follow Scripts > Part Gizmos 2D.
    • NOTE: You can't add Part Gizmos 2D without adding Aim IK Behaviour 2D.
  • In this script, you see some properties.
  • In the Part, you need to add the part rig (Or sprite).
    • NOTE: You must select the part that exists in the Chest Parts of Aim IK Behaviour 2D script.
  • If you enable Show Part Line, the chest part line showing in the editor menu.
  • In the Part Line Color, you can set the chest part line color.