- Home /
animation.Blend() not playing
I have to have an animation in a parent object play in order for some events to work (because it has an animation event). The rest of the script which would activate the animation works (I checked using debug logs), but the animation itself won't play. I need the animation to be able to be played while the character is moving (this is why I thought I'd use animation.Blend()) Here's the code for the animation so far:
var MainM : GameObject;
var caseSwitch : boolean = true;
function Start(){
MainM = transform.parent.transform.parent.transform.parent.transform.parent.transform.parent.transform.parent.transform.parent.transform.parent.transform.parent.transform.parent.gameObject;
//MainM is a very distant ancestor!
MainM.animation["Throw"].wrapMode = WrapMode.Once;
}
function Update(){
//[...]
if(Input.OnMouseButtonDown(0) && caseSwitch){
MainM.animation.Blend("Throw");
caseSwitch = false;
}
}
I've also tried to use animation.Play() and animation.CrossFade() instead of animation.Blend(), which yielded the same, nonexistent results. Also, I've tried to, instead of using transform.parent, assign the game object in the inspector. No change in results.
==========================================================================================
Edit: animation.Blend(), animation.CrossFade(), and animation.Play() have all failed. The source of the problem is most likely something with the animation itself. I have tried re-making the animation with no success. Any suggestions to help with re-animation and fixing the problem this way is appreciated. Thank you.
==========================================================================================
Nope... There's some if statements which control whether or not the animation plays. These if statements also affect other variables (like the number of objects that the player has available to throw). The rest of the stuff is activating (once, not continually), but the animation isn't playing at all. I'll add a bit to the shown code to symbolize this.
Yeah what I mean is that Blend may restart the animation every time you call it so it should be triggered and not called continually when in that state.
Oh really ugh. Really sorry, I'm going to have to leave you too it for a bit. I'll think on...
This has got to be something to do with the animation oh hell. $$anonymous$$gest you edit your question and put the fact that our investigation has pretty much failed in there in bold :) I can't think what else to suggest...
Answer by dylanfries · Jun 29, 2012 at 12:42 PM
Make sure the animation you are calling has a higher blend weight then the animation already playing. If it is lower, the animation will be considered playing but will not have any influence on your model. Also make sure the animation weight is set to 1.0 ( or less if your want to only partially apply it.
Actually the blend weights are normalized and allocated proportionately. A lower blend weight does not mean the animation won't play, it just means it would have a lower effect. Having layers does cause this problem as higher level weights are allocated first.
Your answer

Follow this Question
Related Questions
Animation precision? 0 Answers
Can I make animations snap to a frame? 1 Answer
Accessing a child's animation to play or stop it 2 Answers
Animation of throw spear 1 Answer
Animation does not play in relative position, even with parenting 5 Answers