x


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; }

more ▼

asked Mar 19 '12 at 08:37 PM

yusefkerr gravatar image

yusefkerr
2 4 4 5

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3807
x336
x18

asked: Mar 19 '12 at 08:37 PM

Seen: 509 times

Last Updated: Mar 20 '12 at 01:31 AM