-
Notifications
You must be signed in to change notification settings - Fork 25
Using Aim IK in Unity 2D | version 2.x
Ehsan edited this page Aug 14, 2022
·
1 revision
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
orAim-IK Unity Package
file.- If you download the
Aim-IK.dll
file, you should make a folder in your UnityAssets
folder with the namePlugin
. Then putAim-IK.dll
file to it.
- If you download the
- But if you downloaded
Aim-IK.unitypackage
file, go to Unity. In theAssets
folder, press right-click and then click onImport package > Custom Package...
. Then chooseAim-IK.unitypackage
and click onImport
button. - Now, Aim-IK is ready to use!
- Select your character.
- Press
Add Component
. FollowScripts > 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 inSmooth Time
property (The standard value ofSmooth 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
andMax
variables, you can use theHead Limit Rotation
option (NOTE: If you want to limit the rotation, enableActive
check-box).
- In the
- 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 twoMin
andMax
variables.
- In the
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 addedAim IK Behaviour 2D
previously. - Click on
Add Component
. FollowScripts > Head Gizmos 2D
. - Now, the
Head Gizmos 2D
added successfully!-
NOTE: You can't add
Head Gizmos 2D
without addingAim IK Behaviour 2D
.
-
NOTE: You can't add
- 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.
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 addedAim IK Behaviour 2D
previously. - Click on
Add Component
. FollowScripts > Part Gizmos 2D
.-
NOTE: You can't add
Part Gizmos 2D
without addingAim IK Behaviour 2D
.
-
NOTE: You can't add
- 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
ofAim IK Behaviour 2D
script.
-
NOTE: You must select the part that exists in the
- 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.