x


Running and attacking java problem

Hi, I'm new to programming and I could use a little help. I'm trying to make it so that when my character is running and I hold the attack button that the running attack animation plays.

    function Start () {
animation.wrapMode = WrapMode.Loop;

animation["attack"].wrapMode = WrapMode.Once;

animation["attack"].layer = 2;

animation["run"].layer = 1;

// Stop animations that are already playing

animation.Stop();
}
function Update () {

if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("run");
else
animation.CrossFade("idle");

// Shoot
if (Input.GetButtonDown ("Fire1"))
animation.Play("attack");

//Shoot whilst running
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1 (Input.GetButtonDown ("Fire1")) )
animation.CrossFade("runattack");
}
more ▼

asked Apr 25 '12 at 05:19 PM

imaethan gravatar image

imaethan
17 1 3 5

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

2 answers: sort voted first

Make the attack animation's blend mode 'additive'

animation["attack"].blendMode = AnimationBlendMode.Additive;

If you play that animation now, it will be played on top of any other animations, i.e. the animation for the lower body.

more ▼

answered Apr 25 '12 at 05:39 PM

Piflik gravatar image

Piflik
5.4k 15 26 44

Thanks :) much appreciated

Apr 25 '12 at 07:44 PM imaethan
(comments are locked)
10|3000 characters needed characters left

Thank you very much :)

more ▼

answered Apr 25 '12 at 08:16 PM

imaethan gravatar image

imaethan
17 1 3 5

(comments are locked)
10|3000 characters needed characters left
Your answer
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
x3465

asked: Apr 25 '12 at 05:19 PM

Seen: 263 times

Last Updated: Apr 25 '12 at 08:16 PM