- Home /
Use IK or what?
I want to add aiming to my game. It is 2.5D and I only want it to aim up and down according to the crosshair position.
I already programmed the rotating crosshair and the player's ability to aim directly at it. Now I just need animation to make it work. How can I do this kind of aiming (shown in the video)?
I only want to aim up and down. Also, I do not want to spend money on Final Ik just for one script. What can I do and how do I do it?
Answer by Q-nn · Jul 13, 2014 at 09:09 AM
If it's 2D (i.e. you only have one axis to rotate) then it's pretty trivial and you should be able to implement it yourself / google it.
If it's 3D, I've had some success with this package: https://www.assetstore.unity3d.com/en/#!/content/1829.
Ignore all of the prefabs and demo scene
Use the "IKLimb.cs" script (last time I used this I needed to rename the class to match the filename)
Put the IKLimb component on an object that is NOT part of the arm hierarchy
Set up the various arm and target transforms on the controller
For weapon aiming, you may need to have the weapon itself rotating to "look at" the crosshair and put both arms as IKLimbs to hold the weapon.
Depending on your situation, you could also have an animation that lerps between looking straight up and looking as far down as allowed. Sample this animation with normalizedTime (0..1) based on the current aiming angle. If this can work for you and won't require heaps of individual animations for different equipment or something, I would recommend it as it will be much more finely controllable.
Does not work. I don't want to use this package because my character is a single mesh, not multiple meshes.
Your answer
Follow this Question
Related Questions
Aiming to the crosshair 1 Answer
weapon aim when shooting 0 Answers
Aiming Down Sights Problem 2 Answers
Make crosshairs disappear while aiming 0 Answers
Third Person Shooter (TPS) aiming like Uncharted / MaxPayne3 0 Answers