- Home /
How to avoiding Occlusion in Humanoid Animation
Hi,I am new to unity3D. I trying to animating human avatar using kinect sensor. i can able to animate the avatar. But the hands and legs are not in stable it moves and goes inside the body area. it means i facing occlusion while animating. How to handle this? . please anybody help me to resolve this......
Answer by Cherno · Sep 07, 2014 at 11:06 PM
Hmm, I don't know anything about kinect, but if the avatar has a skeleton, then you could try giving each bone (or at least the ones giving you trouble) a little script that restricts it's localRotation (actually, use localEulerAngles so you can just set the rotation limits as a Vector3). In the Update() function of the script, you just check if the local rotation is inside the minimal and maximal degree values. Something like this (not tested):
public Vector3 minRot;
public Vector3 maxRot;
void Update() {
Vector3 newRot = transform.localEulerAngles;
if(transform.localEulerAngles.x < minRot.x) {
newRot.x = minRot.x;
}
if(transform.localEulerAngles.x > maxRot.x) {
newRot.x = maxRot.x;
}
if(transform.localEulerAngles.y < minRot.y) {
newRot.y = minRot.y;
}
if(transform.localEulerAngles.y > maxRot.y) {
newRot.y = maxRot.y;
}
if(transform.localEulerAngles.z < minRot.z) {
newRot.z = minRot.z;
}
if(transform.localEulerAngles.z < maxRot.z) {
newRot.z = maxRot.z;
}
transform.localeulerAngles = newRot;
}
This could also be made even easier with Mathf.Clamp.
Hope this helps.
when applying i getting like this error:
Error 23 Cannot modify the return value of 'UnityEngine.Transform.localEulerAngles' because it is not a variable
I edited my answer by adding a temporary Vector3. In C#. it's not possible to directly change xyz values of position or rotation.