Took a couple mins to get used to your accent 😅, but great tutorial! It's hard to find anything for the built-in IK system, or intermediate coding topics in general, so much appreciated 💜 Doing 1v1 combat animations with Timeline, and the built-in IK is more performant than the Store/custom options. (Appreciated the humor too - was thinking "Ahh, the _The Exorcist!_" right as you said it 😂)
Great Video, helped me a lot! One little note: Script in question must be attached to a Game Object with an Animator component otherwise the OnAnimatorIK() does NOT get called.
How would you go about using a gun model to point exactly where your mouse is aimed and then using IK to get the player model to grab the gun? Would it be very hard to do in Unity 5 now?
Great script, but just to give everyone a head's up on using this on a character that's not in a predetermined position at the start of your scene - you should disable the IK until your feet are actually on the ground. You can use the raycast, but don't try to place the feet until they're actually hitting the ground.
In a real project, you'd add a layerMask to the raycast and some kind of isGrounded check before any of it. And maybe move the physics checks to FixedUpdate. But this is a good tutorial - focuses on the important stuff.
Great Tutorial, Loved 16:30-> he doesnt have a lot of left feet, he only has one ;-) made me laugh a lot ;-) really solid tutorial over all though, with a lot of information and no bullshit, great work mate!
Φίλε καλησπέρα , απο την ποροφορα σου λέω , είναι σίγουρα έλληνας χαχαχα. φτιάχνω ενα VR game για πτυχιακή και με έχεις βοηθήσει φουλ με αυτά τα Videos !!!! Αν σε ενδιαφέρει κατι σε VR hit me up
Thank you very much! I have a question regarding the origin positions to use in Raycasts. In the Update method, why do we set the origin Vector3 as a TransformPoint(Vector.zero) rather than the foot.position? The maths evades me. I tried that variable but it's not as "polished" as yours. Thanks!!
You turn the local position to world position with TransformPoint(). I don't really remember what I did in the video exactly but if a transform is parented under another gameobject or it's part of a rig, then it's usually wise to convert the position to world.
Sorry about my bad english. I mean, the beginning of the video you put the SetIKPositions and SetIkHintPosition etc... after that you improved the SetIKPositions (for the feets) , i was wondering if you would do the same with SetIKhintPosition's Thanks a lot.
Im a bit confused, i think tis cause of the character controller script, but, my code is the same as your and it pretty much works. But when i turn my isTrigger on the collider on and try to walk over a small object like you do his foot lifts to where to needs to be but does not lift the character like yours does :/ If i turn the trigger off it works, but then only on slopes. Then when in idle, his foot moves back to the plane because the raycast moves past the object the foot lifted onto during the walk animation
The controller was more like an example here and not really a full working one, you need to handle the elevation of the character differently in this case.
May i ask how your character was being lifted up with isTrigger turned on in your collider? I understand your controller was an example, but using my controller i was unable to reproduce the same results. (I tried the default third person controller and a small rigidbody controller i made. Does the character movement have to be based off animation and not physics for it to work as it does in your example?)
I think I just raised the collider a bit higher from what it is, so his feet will go through the floor if there wasn't any IK. it's at 29:55 , of course this probably isn't that elegant for an actual game
Thanks for tutorial but i have a problem about curves ur code is good for moving back and forth but what about left and right because my character moves side ways and has side walk animations too I tried to get distance of each leg and assign them to the opposite one. for example: if(left foot goes up) { increase the right foot weight & decrease left leg weight } if(right foot goes up) { increase the left foot weight & decrease right leg weight } result was bad "So" Help
Hi, i setted up exactly as what you do from the beginning to 5:29, but when moved my IKtarget close to my character's leg, his knee didn't bent, pls help me
Is there no way of deciding two points at either end of the foot to avoid glitched and restraints where the character cannot walk there as its not possible for the animation.
For some reason, I need to do the raycast etc for the foot IK in OnAnimatorIK or it doesn't work correct (at least not without deactivating and activating the script in the inspector while running). Tried both Update and FixedUpdate for the raycasts, for some reason the Animator gives wrong position for the feet, like without an animation.
I have a weird question. I am a 3D generalist thinking about taking up game design as a potential hobby but I currently have no experience. Something I want to do is create a simple mech simulation where by the IK animation itself drives the forward movement (the actual foot friction) like in Sumotori Dreams th-cam.com/video/D1Cb6EzeEPY/w-d-xo.html but with the anti-roll feature you often see on vehicles to prevent them from rolling in order to simulate an internal gyroscope that turns off in the event the tilt is too extreme in order to simulate falling over if on a grade too steep or struck be a very hard attack. Would it be possible? P.S. You might see this question on other videos as I am asking around. P.P.S. I am well aware that even if it were possible that it would likely be quite beyond what a beginner could hope to achieve so I expect a lot of learning first. Thanks!
Everything is possible if you think the logic behind it and that's pretty much the hard part, everything else can be done. In the video you linked I don't see anything that is beyond Unity's capabilities tbh
Thanks for this video. It's a big help. Can somebody please explain me the curves, LeftFoot and RightFoot? Because, it seems as if the value of leftfoot becomes 0 when leftfoot is down on ground but it should be the opposite and same for the rightfoot. I am confused.
There's to ways to apply them. One is exactly as you add them, so 0-1 where one is enabled and the other is the exact opposite, so when you want to disabile it you add it to 1 and substract from 1. The second way is more for the cases that you want the IK always open but you use the curves to disable it. While the opposite is for the cases that you want to enable IK just for one animation
i tried to find about terms like " Hint " and " Weight ", what they actually mean you please point me to thr right direction where i can get to know about these terms ?
When you use IK, it's basically an interpolation between the starting position a bone (or a chain of bones) will have, towards the target position. In the context of IK, the starting position is the position the animation has. Now weight is basically the influence towards that position, so in a percentage of 0 to 1 (1 being 100%) will the bone be towards the target position. Hint is basically the where the midpoint of the chain should be looking, so basically if you have a chain of two bones, where those bones should look if the target position is shorter than the length of the chain. You can find more info here docs.unity3d.com/Manual/InverseKinematics.html however everything that has to do with IK is basically applied trigonometry
Had the same problem, fixed it by adding these two lines in OnAnimatorIK() lpos = anim.GetIKPosition(AvatarIKGoal.LeftFoot); rpos = anim.GetIKPosition(AvatarIKGoal.RightFoot); Think it is caused by models we are using. @Sharp_Accent Thank you so much!!!
Ah! Great! and thanks for the immediate reply! I have another doubt though.. is your method of using raycasting advised for such similar situations and when working in games for mobile? as raycasting can be taxing on mobiles :P
my character keeps floating up does anyone have this problem ? No errors Edit: I fixed this by baking position and rotation into pose but my walk animation will not play
I ve problems with those hint objects, my code is looking exactly the same as yours, but i can't get it to working right, any ideas or thoughts about it? Would appreciate it
I'm going to guess that you forgot to assign the weight to it. It's like the other ik goals, you have to assign both a target position and a target weight, separate from the avatarIkgoals. It's basically this two Animator.SetIKHintPosition and Animator.SetIKHintPositionWeight. docs.unity3d.com/ScriptReference/AvatarIKHint.html
These are my lines of code. anim.SetIKHintPositionWeight(AvatarIKHint.LeftKnee, ikWeight); anim.SetIKHintPositionWeight(AvatarIKHint.RightKnee, ikWeight); anim.SetIKHintPosition(AvatarIKHint.LeftKnee, hintLeft.position); anim.SetIKHintPosition(AvatarIKHint.RightKnee, hintRight.position);
I have set the Foot IK/Foot placement, with the complete script, it works, but the foots follows the Root X & Z orientation, or sometimes the foot looks to the original position, why this happens?
The collider layer is set Ignore Raycast, i checked the script as i can, cause i dont know so much about Vector3, and about Quaternons, i need to learn about that. Maybe the axis of the feet bones is the problem...
My Character from Mixamo is great, I setup layers and he works perfectly aiming, crouching, running, jumping. I wanted to add a aiming weighted system like u have here for his hands rather than feet. The code seems to have no effect on character. I added ik pass to base layer, I Named my c# script ikcontrol and used OnAnimatorIK(){} as function name? U have any Idea whats wrong ?
Hey, I'm still on first half of the tutorial and have a problem. On flat ground, idle animation and IK the legs sort of both equally slide off to the right and stay there. I set up everything exactly and quadruple checked it. When I move the char up way above ground the feet move under him but when on normal height they slide off to some direction. Usually to the right. Not necessarily attached to the floor Tested with no colliders or any other script attached. And don't think the knees are bending at all. Unity 5.5 here. Any ideas? xD EDIT: Seems to be working if I use a different model. I'm using the Challenger from The Blacksmith Unity demo and it doesn't work on it. I don't know why. Everything seems set up right in the avatar, but it doesn't work and using some other avatar doesn't work either.
I came to the conclusion the Unity's Challenger character I'm using is rigged weird or something, so its doing that. It's Avatar seems properly configured though. With a Mixamo character its all fine. I followed using a combat stance idle. Didn't yet get to the walking part. Thanks for the tutorials. I'll move to the climbing series soon, after I mess with the basics a bit. :) Wish I could import the Challenger to Blender and see whats wrong with it. But Blender is giving me errors when I try to import.
There's an import .fbx option, and I haven't used it much other than reimporting my own models I previously exported, but yeah it seems to sometimes not like what you're importing.
It only works with some versions of .fbx and not always, it's really bad implemented. It was stable at 2.76 something i think but still had a lot of problems
5 minutes in, 4 compiler errors... damn it. UnityEngine.Animator does not contain a definition for SetIKPositionWeight or SetIKPosistion. What am I doing wrong?
anim.getFloat("LeftFoot"); return 0 all the time, i already configure the corves but the ik only works if i set lFweight = 1 manually. can you public the code at the
victor camacho macias Check the spelling, they must have the same name inside the animator as it is in the curves, they are case sensitive so that means they have to be the exact character, so no spaces if you don't have any and capitals where they are needed. If the script doesn't gives an error then the problem is from the settings inside Unity
please answer someone please please please. my first person camera has a hand. the hand wants to interact with,say,a valve. it has to pull it down. how should i do this? in a little detail please.
Animate the valve, but an IK target as a child of the valve, then use that IK target for the hand you want to use. If you have an animation for the hands as well you can use curves to be exact on when the hands are touching the valve or not
You need to make a custom ik solution, there's a few ways to do that and I did on in the past (in Unity 4). There's also a few free ones out there and of course paid ones.
With this docs.unity3d.com/ScriptReference/Animator.GetBoneTransform.html if it doesn't include the bone you want you can hardcode, like get the chest, then get the parent of the chest etc.
Jj R Yes. As he mentioned, all rotations and physics codes are to be updated on LateUpdate(). You wouldn't wanna update those rotations every time. You'd only want them to update when everything else is drawn. Rotating a bone is just like rotating any cube or capsule too. They are just transforms too.
Physics must go inside FixedUpdate() not LateUpdate(), because we have animations on our character in every frame they reset the position of every bone to match that of the animations, LateUpdate() runs after the animator so if you won't to change the position of a bone you need to do it there, otherwise you will be trying to manipulate the transform of the bone on the same frame so you won't have good results if any
It might be due to randomness... but as I was skipping most of the video to see what this is all about, (Instead of wasting 1h16 of my time in case I already know what it's about) wherever I clicked on the time bar... it almost always started with a sentence that seems to be overly used in this video : "So..." "So..." "So..." Makes me remember of an old teacher I had in high school would could say the exact sentence "This is really important. Really." over 40 times in a single hours. XD Note. This is not a rant. Only a opinion about something I noticed. ;)
Hey guys, got a problem... my IK just doesnt work, got the scripts exactly as you but it just doesnt start.. Not sure why, i use Networking to spawn my character on map etc , but IK shouldnt have problems with that right? It looks like it just doesnt start..Help?
Tick IK pass on the animator (on all layers that are affected), make sure you add weight to the IK, that's all there is to it. Of course assign targets too
Thanks for your quick response, my mistake was that my character prefabs rig was Generic not Humanoid. That's kinda embrassing but i got it now, but thanks for help :) I'm making a game for engineering degree and when i'm done i will make some videos of it :) Will past link here if u are interested :) Thanks again.
Ok, i have tried doing your tutorial like 3 times, there is always something wrong, is it because im using Personal edition? My mixamo character just doesnt want to cooperate with IK , i mean it works but it looks weird :/
Hmmm.. The legs just sticks together and they dont make that "step" like your character, i tried doing something with hands but it just didnt work. I thought maybe there is something with my unity version or mixamo character , didnt have time but today i will try to do it with standard charavter asset to check if there lies the problem.
48:20 - everything you need to know
+Ioan Katalin :P
Ha ha ha
oh no! leave alone to me!
This is probably the most useful Unity IK instruction around right now!
+Jason Cook Thanks! Check on my other series too, the new TPS i'm doing right now for example, I have usage for it on an in game usage (IK targeting)
Took a couple mins to get used to your accent 😅, but great tutorial! It's hard to find anything for the built-in IK system, or intermediate coding topics in general, so much appreciated 💜 Doing 1v1 combat animations with Timeline, and the built-in IK is more performant than the Store/custom options.
(Appreciated the humor too - was thinking "Ahh, the _The Exorcist!_" right as you said it 😂)
Thank you so much for this video. This is the first video I watched on implementing IK in unity. Not disappointed.
You're welcome
This is amazing and it's released on 2015. This channel is the top level on TPS Character Controller which is a whole area of game development.
I'm biased but i'd say top level at everything i touched xD
Bro you are absolutely amazing. Struggled for so long trying to work out inverse kinematics. I'm really grateful to you.
Great Video, helped me a lot! One little note: Script in question must be attached to a Game Object with an Animator component otherwise the OnAnimatorIK() does NOT get called.
Your tutorials are incredibly helpful !
They make things much less intimidating when talking about complex animation.
Thanks !
Thanks! :)
This is the thing I was looking for so long! Thanks man
This is exactly what i have been looking for. Thanks man.
Vyebrows :D
Great video, really helpfull. But how do you make your character stand on the ground without collider?(At 40:07 where you make collider trigger)
I'm definitely late to finding this video but great job man! You're a life saver!
Great video, super useful! Got it all up and running really fast. Thanks.
Glad to hear it still helps after all these years
please can you help me?
how can you get left foot, right foot, and l, r hint in camera holder.. when i dorop the original leg in this it make wrong!!
φιλε ενα μεγαλο μπραβο για τα tutorials.συνεχισε ετσι....
buddy a big bravo for your tutorials.keep it up...
+achilleas zapantis Euxaristo polu! :D
hi, how do u rotate your character using ik in 51:20 ?
Exactly what I needed. Thank you so much :)
How would you go about using a gun model to point exactly where your mouse is aimed and then using IK to get the player model to grab the gun? Would it be very hard to do in Unity 5 now?
It's simple. Set the gun as a child of the camera, ik the hands to the gun.
Great script, but just to give everyone a head's up on using this on a character that's not in a predetermined position at the start of your scene - you should disable the IK until your feet are actually on the ground. You can use the raycast, but don't try to place the feet until they're actually hitting the ground.
In a real project, you'd add a layerMask to the raycast and some kind of isGrounded check before any of it. And maybe move the physics checks to FixedUpdate. But this is a good tutorial - focuses on the important stuff.
I have been looking for this for weeks!
Happy to be the 100th like on this vid =)
+Rigved Deshpande =)
This helped me with some problems I had. Thanks!
Great Tutorial,
Loved 16:30-> he doesnt have a lot of left feet, he only has one ;-) made me laugh a lot ;-) really solid tutorial over all though, with a lot of information and no bullshit, great work mate!
Simply Amazing!!
Φίλε καλησπέρα , απο την ποροφορα σου λέω , είναι σίγουρα έλληνας χαχαχα.
φτιάχνω ενα VR game για πτυχιακή και με έχεις βοηθήσει φουλ με αυτά τα Videos !!!!
Αν σε ενδιαφέρει κατι σε VR hit me up
thank you! thank you very much!
the best video tutorial on TH-cam with unity IK system ^__^
Check out the TPS redux series I did too, It's heavily based on the IK system
ty. i'll do :)
The code doesn't work with my Mixamo charatcer, any ideas how to fix this problem?
Excellent tutorial! Thank you so much!
Thank you very much! I have a question regarding the origin positions to use in Raycasts. In the Update method, why do we set the origin Vector3 as a TransformPoint(Vector.zero) rather than the foot.position? The maths evades me. I tried that variable but it's not as "polished" as yours. Thanks!!
You turn the local position to world position with TransformPoint(). I don't really remember what I did in the video exactly but if a transform is parented under another gameobject or it's part of a rig, then it's usually wise to convert the position to world.
Oh yeah. That makes sense. As you say it's wise to convert to world position vectors. Thanks again!
I love this tutorial! It helped me a ton!
Nice accent ;D
Super Like
👍🏻
THnaks a lot for uploading/teaching us very useful stuff
really great stuff , thank you!
Might make a video like climbing?
extremely useful, thanks a lot!
how did you make the IK target left and IK target right mine don't even move my character legs
Why does my right foot react to the IK but the left foot seems to not be affected?
Good video.
But what about the hint's in the knees? don't you restore them?
Restore them?
Sorry about my bad english. I mean, the beginning of the video you put the SetIKPositions and SetIkHintPosition etc...
after that you improved the SetIKPositions (for the feets) , i was wondering if you would do the same with SetIKhintPosition's
Thanks a lot.
If it's needed yes I do it, most of the time you won't need it though. If you look into my climb system you'll see I use the hints there a lot
AAAh!
Thanks a lot, i will check it!
Im a bit confused, i think tis cause of the character controller script, but, my code is the same as your and it pretty much works. But when i turn my isTrigger on the collider on and try to walk over a small object like you do his foot lifts to where to needs to be but does not lift the character like yours does :/ If i turn the trigger off it works, but then only on slopes.
Then when in idle, his foot moves back to the plane because the raycast moves past the object the foot lifted onto during the walk animation
The controller was more like an example here and not really a full working one, you need to handle the elevation of the character differently in this case.
May i ask how your character was being lifted up with isTrigger turned on in your collider?
I understand your controller was an example, but using my controller i was unable to reproduce the same results. (I tried the default third person controller and a small rigidbody controller i made. Does the character movement have to be based off animation and not physics for it to work as it does in your example?)
I think I just raised the collider a bit higher from what it is, so his feet will go through the floor if there wasn't any IK. it's at 29:55 , of course this probably isn't that elegant for an actual game
Thanks for tutorial but i have a problem about curves ur code is good for moving back and forth but what about left and right because my character moves side ways and has side walk animations too I tried to get distance of each leg and assign them to the opposite one.
for example:
if(left foot goes up) {
increase the right foot weight & decrease left leg weight
}
if(right foot goes up) {
increase the left foot weight & decrease right leg weight
}
result was bad "So" Help
Why don't you add curves on those animations as well?
Hi, i setted up exactly as what you do from the beginning to 5:29, but when moved my IKtarget close to my character's leg, his knee didn't bent, pls help me
oh, i figure it out, this' a great video, love it!!!
Can you tell me how you did please ? i have the same problem
try to switch your character model rig to Humanoid
Great tutorial thanks
It amazing, absolutely love it ! But dude, you're left and right are on different sides :D
+WendaF's Yeah I might have been :P
Can I get a Link for this project. I need it...
lol
does foot IK work with an animator over-ride controller? i seem to have issues.
Is there no way of deciding two points at either end of the foot to avoid glitched and restraints where the character cannot walk there as its not possible for the animation.
You could probably just add a bit more logic and restrains to them
For some reason, I need to do the raycast etc for the foot IK in OnAnimatorIK or it doesn't work correct (at least not without deactivating and activating the script in the inspector while running). Tried both Update and FixedUpdate for the raycasts, for some reason the Animator gives wrong position for the feet, like without an animation.
OnAnimatorIK updates after the animator has moved the bones, that's why, so it should have the latest position
I have a weird question. I am a 3D generalist thinking about taking up game design as a potential hobby but I currently have no experience. Something I want to do is create a simple mech simulation where by the IK animation itself drives the forward movement (the actual foot friction) like in Sumotori Dreams th-cam.com/video/D1Cb6EzeEPY/w-d-xo.html but with the anti-roll feature you often see on vehicles to prevent them from rolling in order to simulate an internal gyroscope that turns off in the event the tilt is too extreme in order to simulate falling over if on a grade too steep or struck be a very hard attack. Would it be possible?
P.S. You might see this question on other videos as I am asking around.
P.P.S. I am well aware that even if it were possible that it would likely be quite beyond what a beginner could hope to achieve so I expect a lot of learning first.
Thanks!
Everything is possible if you think the logic behind it and that's pretty much the hard part, everything else can be done. In the video you linked I don't see anything that is beyond Unity's capabilities tbh
Awesome, thanks for the reply!
Thank you for this tutorial :)
michal ezo You're welcome :)
Wonderful tutorial. But why didin't post code?
What does the "camera holder" contain?
why aren't the knees bending in 32:05 for me???
I'm running into the same issue...Have you got a solution yet? :)
Such an childhood that i watch
he made eye ik even tho he doesnt see the eyes right??
Thanks for this video. It's a big help.
Can somebody please explain me the curves, LeftFoot and RightFoot? Because, it seems as if the value of leftfoot becomes 0 when leftfoot is down on ground but it should be the opposite and same for the rightfoot. I am confused.
There's to ways to apply them. One is exactly as you add them, so 0-1 where one is enabled and the other is the exact opposite, so when you want to disabile it you add it to 1 and substract from 1.
The second way is more for the cases that you want the IK always open but you use the curves to disable it. While the opposite is for the cases that you want to enable IK just for one animation
Thanks for answering :). I'll try to implement it.
are you the same person of the chanel sharpstance?
Indeed :)
And how I can play animations which move weapon? Attach weapon to hand?
Is this character/model is free in asset store? Please message me..
i tried to find about terms like " Hint " and " Weight ", what they actually mean you please point me to thr right direction where i can get to know about these terms ?
When you use IK, it's basically an interpolation between the starting position a bone (or a chain of bones) will have, towards the target position. In the context of IK, the starting position is the position the animation has. Now weight is basically the influence towards that position, so in a percentage of 0 to 1 (1 being 100%) will the bone be towards the target position. Hint is basically the where the midpoint of the chain should be looking, so basically if you have a chain of two bones, where those bones should look if the target position is shorter than the length of the chain. You can find more info here docs.unity3d.com/Manual/InverseKinematics.html however everything that has to do with IK is basically applied trigonometry
Thanks a lot. Its really helpful.
hey man great tutorial but my feet are both going to the middle/they look like im trying to balance my feet standing together
Had the same problem, fixed it by adding these two lines in OnAnimatorIK()
lpos = anim.GetIKPosition(AvatarIKGoal.LeftFoot);
rpos = anim.GetIKPosition(AvatarIKGoal.RightFoot);
Think it is caused by models we are using.
@Sharp_Accent Thank you so much!!!
when making a recoil system for the shooting of a gun, is it a good idea to manipulate the transforms that the IK is dependent upon?
+rasengan720 Depends which ones you mean, but in most cases I can imagine there's going to be any problem
+C Sharp Accent Tutorials *can't imagine
Ah! Great! and thanks for the immediate reply! I have another doubt though.. is your method of using raycasting advised for such similar situations and when working in games for mobile? as raycasting can be taxing on mobiles :P
Well depends again, I can't imagine a mobile game that has a need for foot IK tbh, that's luxuries for the mobile market :P
haha true that!
I've been having a big problem where when I enter play mode, my models feet are rotated sideways in the same direction.
You need to find the correct rotation based on your model that's why
I'm confused to what you mean as in the correct rotation of my model?
Pls UserInput.cs link.
Thanks you sooo much I finally watched this and it works great. Thanks!
You're welcome :)
Hey Dorothy! It's foxdit from VRTK's slack. Looks like we found the same video :)
Ravanous haha! Yeah it's a really good tutorial. Works great!!!
Does AvatarIKGoal only work for Mecanim? How does Unity recognize this?
Jj R Mecanim only
my character keeps floating up does anyone have this problem ? No errors
Edit: I fixed this by baking position and rotation into pose but my walk animation will not play
I ve problems with those hint objects, my code is looking exactly the same as yours, but i can't get it to working right, any ideas or thoughts about it? Would appreciate it
Depends what isn't working right
the elbow bone is basically unaffected
I'm going to guess that you forgot to assign the weight to it. It's like the other ik goals, you have to assign both a target position and a target weight, separate from the avatarIkgoals.
It's basically this two Animator.SetIKHintPosition and Animator.SetIKHintPositionWeight.
docs.unity3d.com/ScriptReference/AvatarIKHint.html
These are my lines of code.
anim.SetIKHintPositionWeight(AvatarIKHint.LeftKnee, ikWeight);
anim.SetIKHintPositionWeight(AvatarIKHint.RightKnee, ikWeight);
anim.SetIKHintPosition(AvatarIKHint.LeftKnee, hintLeft.position);
anim.SetIKHintPosition(AvatarIKHint.RightKnee, hintRight.position);
if the ik weight is set then you probably have the positions way to close to the character, they need to be very far away from him to see real change
I have set the Foot IK/Foot placement, with the complete script, it works, but the foots follows the Root X & Z orientation, or sometimes the foot looks to the original position, why this happens?
You don't update correctly the target positions probably, recheck your script and make sure you're not hitting the collider of your controller
The collider layer is set Ignore Raycast, i checked the script as i can, cause i dont know so much about Vector3, and about Quaternons, i need to learn about that.
Maybe the axis of the feet bones is the problem...
ευχαριστώ πολύ φίλος
My Character from Mixamo is great, I setup layers and he works perfectly aiming, crouching, running, jumping.
I wanted to add a aiming weighted system like u have here for his hands rather than feet.
The code seems to have no effect on character. I added ik pass to base layer, I Named my c# script ikcontrol and used OnAnimatorIK(){} as function name?
U have any Idea whats wrong ?
is it because my avatar is generic?
+Brett Palmer Yeah
+WendaF's Any ideas how to fix this maybe?
You have to click on the model, select Rig in right panel, and then chanke from generic to humanoid
Thanks! It worked, but now there's the next problem, I set my animations to humanoid as well, but now they're kinda screwed up
Why use -Vector3.up instead of Vector3.down?
Force of habit
is it possible to turn on Foot IK by script
What do you mean? Active the script by another script?
Hey, I'm still on first half of the tutorial and have a problem. On flat ground, idle animation and IK the legs sort of both equally slide off to the right and stay there. I set up everything exactly and quadruple checked it. When I move the char up way above ground the feet move under him but when on normal height they slide off to some direction. Usually to the right. Not necessarily attached to the floor Tested with no colliders or any other script attached. And don't think the knees are bending at all. Unity 5.5 here. Any ideas? xD
EDIT: Seems to be working if I use a different model. I'm using the Challenger from The Blacksmith Unity demo and it doesn't work on it. I don't know why. Everything seems set up right in the avatar, but it doesn't work and using some other avatar doesn't work either.
If it's sliding away or any other weird behavior, it's from the scripts. The target position probably updates without a need to.
I came to the conclusion the Unity's Challenger character I'm using is rigged weird or something, so its doing that. It's Avatar seems properly configured though. With a Mixamo character its all fine. I followed using a combat stance idle. Didn't yet get to the walking part. Thanks for the tutorials. I'll move to the climbing series soon, after I mess with the basics a bit. :)
Wish I could import the Challenger to Blender and see whats wrong with it. But Blender is giving me errors when I try to import.
Yeap blender doesn't import .fbx, one of the biggest reasons I stopped using it. It makes editing or fixing stuff pretty much impossible
There's an import .fbx option, and I haven't used it much other than reimporting my own models I previously exported, but yeah it seems to sometimes not like what you're importing.
It only works with some versions of .fbx and not always, it's really bad implemented. It was stable at 2.76 something i think but still had a lot of problems
5 minutes in, 4 compiler errors... damn it.
UnityEngine.Animator does not contain a definition for SetIKPositionWeight or SetIKPosistion.
What am I doing wrong?
+flooblybub You need pro version of unity :P
+SmartLessGamer not really you don't if you use Unity 5 :P
Oh good :)
your script in this tutorial not working to me !! Help me .. i have unity 5.3.2f1
You need to have a humanoid character and check IK Pass on the animator for the IK to work
hi, i have problems with my model.
I made IK, and i don't have errors. but IK work so wierd: Bones don't move, when IK is working
+Aki Kato oh, np)) Now it works)) Thanks for tutorial))
how did you fix it?
anim.getFloat("LeftFoot"); return 0 all the time, i already configure the corves but the ik only works if i set lFweight = 1 manually. can you public the code at the
victor camacho macias Check the spelling, they must have the same name inside the animator as it is in the curves, they are case sensitive so that means they have to be the exact character, so no spaces if you don't have any and capitals where they are needed. If the script doesn't gives an error then the problem is from the settings inside Unity
please answer someone please please please.
my first person camera has a hand. the hand wants to interact with,say,a valve. it has to pull it down. how should i do this? in a little detail please.
Animate the valve, but an IK target as a child of the valve, then use that IK target for the hand you want to use. If you have an animation for the hands as well you can use curves to be exact on when the hands are touching the valve or not
thanks man. ill subscribe to your channel from both my accounts now.
would you be available for a couple of months to help set up our animation pipeline? It would be great to get you involved!
+Pixel Issue The last time I had a couple of months available was like a decade ago hah :P
I know what you mean :D I think I'm putting about 18 hours a day into my game :D No problem if you're not available. Keep up the great work (y)
How would you go about doing this on a generic rig (non-humanoid).
You need to make a custom ik solution, there's a few ways to do that and I did on in the past (in Unity 4). There's also a few free ones out there and of course paid ones.
I really wish I watch this first , then spend 10 times the length of this video trying to figure it out myself.
where can i take assets ?
Asset store :)
@@SharpAccent what is the asset's name? Built in IK?
how do i acces the spine of the avatar?
With this docs.unity3d.com/ScriptReference/Animator.GetBoneTransform.html if it doesn't include the bone you want you can hardcode, like get the chest, then get the parent of the chest etc.
I love this channel
But can you please add automatic English subtitle? I don't understand what are you saying
It's not available for videos longer than 10 minutes
Thank you so so much! U re so awesome!
thanks for this video every thing is working Except my elbow can you tell me how i can fix it thanks again :)
Can bones be manually rotated from script?
Jj R Yes, but you'll have to do it inside LateUpdate() see the custom IK video for more info
I meant rotating the bone in game in the build. Is there a way?
Jj R Yes. As he mentioned, all rotations and physics codes are to be updated on LateUpdate(). You wouldn't wanna update those rotations every time. You'd only want them to update when everything else is drawn.
Rotating a bone is just like rotating any cube or capsule too. They are just transforms too.
Physics must go inside FixedUpdate() not LateUpdate(), because we have animations on our character in every frame they reset the position of every bone to match that of the animations, LateUpdate() runs after the animator so if you won't to change the position of a bone you need to do it there, otherwise you will be trying to manipulate the transform of the bone on the same frame so you won't have good results if any
I see. My bad, thanks. :D
Thank you
Does this work on Unity Free version?
+Rahul Das Unity 5 yes
Is this work now?
Hi. Can you make a tutorial with eye blinking? Gia sou
Eye blinking is done with blend shapes usually, it's more of modelling rather than scripting
It might be due to randomness... but as I was skipping most of the video to see what this is all about, (Instead of wasting 1h16 of my time in case I already know what it's about) wherever I clicked on the time bar... it almost always started with a sentence that seems to be overly used in this video :
"So..."
"So..."
"So..."
Makes me remember of an old teacher I had in high school would could say the exact sentence "This is really important. Really." over 40 times in a single hours. XD
Note. This is not a rant. Only a opinion about something I noticed. ;)
+Creations Maxo (Maxime Bolduc) So.. yeah I noticed I do that a lot hah
Creations Maxo "So" isn't a sentence...
Joel H but the scentence starts with it
So? :)
I did not work
MY Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class IKHandler : MonoBehaviour {
Animator anim;
public float ikWeight = 1;
public Transform leftIKTarget;
public Transform rightIKTarget;
public Transform hintLeft;
public Transform hintRight;
Vector3 lFpos;
Vector3 rFpos;
Quaternion lFrot;
Quaternion rFrot;
float lFWeight;
float rFWeight;
Transform leftFoot;
Transform rightFoot;
public float offsetY;
// Use this for initialization
void Start () {
anim = GetComponent ();
leftFoot = anim.GetBoneTransform (HumanBodyBones.LeftFoot);
rightFoot = anim.GetBoneTransform (HumanBodyBones.RightFoot);
}
// Update is called once per frame
void Update ()
{
RaycastHit leftHit;
RaycastHit rightHit;
Vector3 lpos = leftFoot.TransformPoint (Vector3.zero);
Vector3 rpos = rightFoot.TransformPoint (Vector3.zero);
if(Physics.Raycast(lpos, -Vector3.up, out leftHit, 1))
{
lFpos = leftHit.point;
lFrot = Quaternion.FromToRotation (transform.up, leftHit.normal) * transform.rotation;
}
if(Physics.Raycast(rpos, -Vector3.up, out rightHit, 1))
{
rFpos = rightHit.point;
rFrot = Quaternion.FromToRotation (transform.up, rightHit.normal) * transform.rotation;
}
}
void OnAnimatorIK()
{
lFWeight = anim.GetFloat ("LeftFoot");
rFWeight = anim.GetFloat ("RightFoot");
anim.SetIKPositionWeight (AvatarIKGoal.LeftFoot, lFWeight);
anim.SetIKPositionWeight (AvatarIKGoal.RightFoot, rFWeight);
anim.SetIKPosition (AvatarIKGoal.LeftFoot, lFpos + new Vector3(0,offsetY,0));
anim.SetIKPosition (AvatarIKGoal.RightFoot, rFpos + new Vector3(0,offsetY,0));
////////////////////////////////////////////////////////////////////
anim.SetIKRotationWeight (AvatarIKGoal.LeftFoot, lFWeight);
anim.SetIKRotationWeight (AvatarIKGoal.RightFoot, rFWeight);
anim.SetIKRotation(AvatarIKGoal.LeftFoot, lFrot);
anim.SetIKRotation(AvatarIKGoal.RightFoot, rFrot);
////////////////////////////////////////////////////////////////////
/*anim.SetIKHintPositionWeight (AvatarIKHint.LeftKnee, ikWeight);
anim.SetIKHintPositionWeight (AvatarIKHint.RightKnee, ikWeight);
anim.SetIKHintPosition (AvatarIKHint.LeftKnee, hintLeft.position);
anim.SetIKHintPosition (AvatarIKHint.RightKnee, hintRight.position);*/
}
}
Can you make a Download Link ?
PixelDev The controller is available on the Advanced Character Controller video. All other scripts are available as a reward for my Patreon backers :)
nice!
UnassignedReferenceException: The variable lookPos of GunCarryingRifle has not been assigned
Does it work in 2D? :P
Nope :P
Ah shit but thx :D
they said cant find avatarik goal
IK?
Inverse Kinematic
Hey guys, got a problem... my IK just doesnt work, got the scripts exactly as you but it just doesnt start.. Not sure why, i use Networking to spawn my character on map etc , but IK shouldnt have problems with that right? It looks like it just doesnt start..Help?
Tick IK pass on the animator (on all layers that are affected), make sure you add weight to the IK, that's all there is to it. Of course assign targets too
Thanks for your quick response, my mistake was that my character prefabs rig was Generic not Humanoid. That's kinda embrassing but i got it now, but thanks for help :) I'm making a game for engineering degree and when i'm done i will make some videos of it :) Will past link here if u are interested :) Thanks again.
Ok, i have tried doing your tutorial like 3 times, there is always something wrong, is it because im using Personal edition? My mixamo character just doesnt want to cooperate with IK , i mean it works but it looks weird :/
No I use personal edition too. It depends what you mean by weird. It's all about the values you give to it if the IK works at least
Hmmm.. The legs just sticks together and they dont make that "step" like your character, i tried doing something with hands but it just didnt work. I thought maybe there is something with my unity version or mixamo character , didnt have time but today i will try to do it with standard charavter asset to check if there lies the problem.
48:24 OH NO
:P
foot and feet
Hands and hends
@@SharpAccent haha englsh is funny. my english is brokn but u can explain good and clear its easy to understand for me.