- Home /
Shaking skinned mesh animations
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?
Looks like my comment response didn't survive the platform change here on UA. As of the origin in world space I start off at zero and the twitching is the same wherever, just that it gets worse when the terrain gets more dense with objects. I haven't worked with animations before so I have a feeling that I do something wrong - perhaps they're not intended to work like this with additive on different layers? Or does the code seem right to what I am trying to achieve? Could it otherwise be that the idle animation that it turns back to has to little movement?
Answer by save · May 19, 2011 at 10:32 AM
The solution turned out to be simple, I put the animation inside FixedUpdate() instead and turned Animate physics on. I guess the animation couldn't somehow sync correctly inside only the Update().
Had the same issue and this fixed it, Thx! I still think it's a weird solution, do all animation updates happen in FixedUpdate?