- Home /
How can I return to the locomotion system after jumping?
Hello, I'm very new to scripting but I've managed to get a character set up with the locomotion system and I'm trying to add a "jump" animation. The character also has the following components:
Alignment Tracker
Character Motor
Character Controller
Player Controller (that I've adapted from the Bootcamp "soldier controller")
Player Animations (that I've adapted from the Bootcamp "soldier animations" script)
I've managed to toggle between 2 of locomotion system's "animation groups" by including the following in my Player Controller script's "GetUserInputs()" function:
if(Input.GetKeyDown(KeyCode.LeftControl))
{
crouch = !crouch;
idleTimer = 0.0;
if (crouch == true)
{
animation.CrossFade("crouch_group",0.5f);
}
else
{
animation.CrossFade("stand_group",0.5f);
}
And I can play a jump animation by adding the following to the same function:
if (Input.GetButtonDown("Jump"))
{
if (Input.GetButtonDown("Jump")== true)
{
animation.CrossFade("jump");
animation["jump"].wrapMode = WrapMode.Once;
}
}
However, there is a real problem here. When the jump animation finishes, the player just slides around in the first frame of the "jump" animation until
a) I press jump again (it plays "jump" and then starts skating again)
b) I press the crouch button (when it rturns to normal locomotion system crouch mode)
I can't work out how to tell the character to automatically go back to the locomotion system "stand" mode after it finishes the "jump" animation. Can anyone point me in the right direction?
EDIT:
I thought I'd found a way round this, but I then ran into trouble when trying to add AddMixingTransforms (to animate just the upper body). The new script looks like this:
if(Input.GetKeyDown(KeyCode.LeftControl))
{
crouch = !crouch;
idleTimer = 0.0;
if (crouch == true)
{
animation.CrossFade("crouch_group",0.5f);
}
else
{
animation.CrossFade("stand_group",0.5f);
}
}
jump = Input.GetButtonDown("Jump");
if (jump == true && !crouch)
{
Debug.Log("Jump has ben pressed");
animation.CrossFade("jump");
animation["jump"].wrapMode = WrapMode.Once;
}
if (motor.grounded && !jump && !crouch && !reload)
{
animation.CrossFade("stand_group");
}
reload = Input.GetButtonDown("Reload");
if (reload == true)
{
Debug.Log("Reload has ben pressed");
var mixTransform : Transform = transform.Find("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1");
animation["reload"].AddMixingTransform(mixTransform);
animation["reload"].wrapMode = WrapMode.Once;
}
Your answer
Follow this Question
Related Questions
Running animation until a certain time/frame 0 Answers
Does any one know how to setup locomotion animations to player movement? 0 Answers
Jump to a specific frame in an animation 6 Answers
Getting this character controll script working right 1 Answer
why will my jump animation only play on multi-jumps? 0 Answers