- Home /
Animation/CrossFade difficulties, Animation won't CrossFade
Hello, I'm new to C# and still learning how to use the language. I'm making an fps and having problems with animations run, walk, and idle. When I walk forward, the walk animation CrossFades nicely from the idle animation and the walk animation CrossFades nicely when going into the idle animation also. But when I hit the "Shift" key to run, it doesn't crossfade at all. It just plays just like Animation.Play would. I'm not sure how to fix this. Any help would be greatly appreciated!
Here's my animation code:
public void AnimationController() {
if(WasStanding && !CharCont.isGrounded)
{
WasStanding = false;
JumpAnimationHolder.animation.Play("JumpAnimation");
}
else if(!WasStanding && CharCont.isGrounded)
{
WasStanding = true;
JumpAnimationHolder.animation.Play("LandAnimation");
}
if(walkingstate == WalkingState.Running)
{
WalkAnimationHolder.animation["RunAnimation"].speed = VelocityMagnitude / RunSpeed * 1.2f;
WalkAnimationHolder.animation.CrossFade("RunAnimation", 0.2f);
}
else if(walkingstate == WalkingState.Walking)
{
WalkAnimationHolder.animation["RunAnimation"].speed = VelocityMagnitude / WalkSpeed * 1.2f;
WalkAnimationHolder.animation.CrossFade("WalkAnimation", 0.2f);
}
else
{
WalkAnimationHolder.animation.CrossFade("IdleAnimation", 0.2f);
}
}
$$anonymous$$aybe posting your code that modify walkingstate can help it becomes clearer.
I doubt this is the root of your problem, so posting as comment only, but I did notice that on line 21 you are setting the speed of "RunAnimation" rather than "WalkAnimation", was this intentional?
@ $$anonymous$$emige No, this didn't fix the problem but thanks for pointing that out, it wasn't intentional. :)
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Animation Doesn't CrossFade At End 0 Answers
Walking animation has wrong rotation 0 Answers
Zooming animation doesn't work 1 Answer