I have a skinned mesh (arms and a steering wheel) with animations that twitch and shakes. The complexity of meshes around it seem to affect the amount of twitching (when approaching areas with dense objects the shakiness and twitching becomes worse). There's no physics affecting the skinned mesh but it is a child of a rigidbody (it doesn't matter if i turn animate physics on, the twitching is still there but gets less frequent).
Here's the code I use to additive go between states in the animation (left/right and so on):
var crossTime = 0.1;
private var rollLeft : AnimationState;
private var rollRight : AnimationState;
private var pitchUp : AnimationState;
private var pitchDown : AnimationState;
private var idleCockpit : AnimationState;
function Start () {
rollLeft = animation["Roll_Left"];
rollRight = animation["Roll_Right"];
pitchUp = animation["Pitch_Up"];
pitchDown = animation["Pitch_Down"];
idleCockpit = animation["Idle_Cockpit"];
animation["Roll_Left"].layer = 1;
animation["Roll_Right"].layer = 1;
animation["Pitch_Up"].layer = 2;
animation["Pitch_Down"].layer = 2;
animation["Idle_Cockpit"].layer = 0;
rollLeft.blendMode = AnimationBlendMode.Additive;
rollRight.blendMode = AnimationBlendMode.Additive;
pitchUp.blendMode = AnimationBlendMode.Additive;
pitchDown.blendMode = AnimationBlendMode.Additive;
rollLeft.wrapMode = WrapMode.ClampForever;
rollRight.wrapMode = WrapMode.ClampForever;
pitchUp.wrapMode = WrapMode.ClampForever;
pitchDown.wrapMode = WrapMode.ClampForever;
rollLeft.enabled = true;
rollRight.enabled = true;
pitchUp.enabled = true;
pitchDown.enabled = true;
rollLeft.weight = 1;
rollRight.weight = 1;
pitchUp.weight = 0.3;
pitchDown.weight = 0.6;
idleCockpit.weight = 0.9;
animation.Play("Idle_Cockpit");
//animation["Idle_Cockpit"].speed = 0.5;
}
function Update () {
var turn : float = Input.GetAxis("Turn");
var elevate : float = Input.GetAxis("Elevate");
rollLeft.normalizedTime = turn;
rollRight.normalizedTime = -turn;
pitchUp.normalizedTime = -elevate;
pitchDown.normalizedTime = elevate;
if(Input.GetAxis("Turn")>0) {
animation.CrossFade("Roll_Left", crossTime);
}
if(Input.GetAxis("Turn")<0) {
animation.CrossFade("Roll_Right", crossTime);
}
if(Input.GetAxis("Elevate")<0) {
animation.CrossFade("Pitch_Up", crossTime);
}
if(Input.GetAxis("Elevate")>0) {
animation.CrossFade("Pitch_Down", crossTime);
}
if(!Input.GetAxis("Turn") && !Input.GetAxis("Elevate")){
animation.CrossFade("Idle_Cockpit", crossTime);
}
}
The animations work well and the blend between them as well, each of them are 5 frames from center to their corresponding clamp-maximum and the idle is just a small movement over 60 frames. They are imported from 3d Studio. What could possibly be wrong, am I missing something?