- Home /
Run Animation Rotation - Position
Hey Guys, Recently I started making an FPS Multiplayer Game. When I reached the animation creation I realized that when I tried to make the Run Animation I changed the rotation of the weapon -45 degrees (everythings fine so far). When the run animation was being interupted by the walk animation (for example when you Get the button up) my weapon does not change its rotation to the default of the walk animation (0 degrees) it just stays the same -45 degrees.. how can i fix that?
Did you have a keyframe for the weapon inside the walk animation?
Is the weapon a child of the hand? It should follow its transform.
I have keyframes which changes the position - rotation of the animation holder where my weapon and the hands are inside, however animation holder is a child of the main camera
Answer by george3d2011 · Aug 23, 2013 at 08:47 AM
public Transform AnimationHolder;
public CharacterController CharCont;
public CharacterMotor CharMotor;
public WalkingState walkingstate = WalkingState.Idle;
public float VelocityMagnitude;
public float WalkSpeed;
public float RunSpeed;
public bool WasStanding;
public void AnimationController()
{
if(WasStanding && !CharCont.isGrounded)
{
WasStanding = false;
WalkAnimationHolder.animation.Play("animationSTANDINGJUMP");
}
else if (!WasStanding && CharCont.isGrounded)
{
WasStanding = true;
WalkAnimationHolder.animation.Play("animationSTANDINGJUMPLANDING");
}
//Run
if(walkingstate == WalkingState.Running)
{
WalkAnimationHolder.animation["animationRUN"].speed = VelocityMagnitude / RunSpeed * 1.2f;
WalkAnimationHolder.animation.CrossFade("animationRUN", 0.2f);
}
//Walk
else if (walkingstate == WalkingState.Walking)
{
WalkAnimationHolder.animation["animationWALK"].speed = VelocityMagnitude / WalkSpeed * 1.2f;
WalkAnimationHolder.animation.CrossFade("animationWALK", 0.2f);
}
//Reloading
else if(walkingstate == WalkingState.ReloadState)
{
WalkAnimationHolder.animation.CrossFade("animationRELOADING", 0.2f);
}
//Staying Put
else
{
WalkAnimationHolder.animation.CrossFade("animationIDLE", 0.2f);
}
}
Here are my codes. I have to say that when the animation RUN is being interupted by the walk animation, the walk animation Plays FINE! the only which goes wrong is that my weapon stays at -45 degrees because my run animation requires -45 degrees (Y). And Yes the weapon is a child of the AnimationHolder and the hands too.
Your answer
Follow this Question
Related Questions
set child object position when playing the animation 0 Answers
Position of GameObject changes when animating 2 Answers
Simple animations - hardcoded or import animation 1 Answer
animation & position problem 0 Answers
Only animate rotation not position 1 Answer