#is there a way i can replicate this

1 messages ยท Page 1 of 1 (latest)

crystal coyote
#

ignore the armor change
what im trying to do is make the character seemlessly transition to shooting while moving when the x key is pressed and one of the arrow keys are moving
here is my animator controller:

#

when i try to do it i get this result:

#

any tips?

vague kettle
#

Use a synced animation layer that has the shooting variants of all the animations

crystal coyote
#

but once i do that

#

how can i trigger said synced animation layer

vague kettle
crystal coyote
#

when should i trigger the weight?

#

when the shoot button is pressed while the character is moving?

vague kettle
crystal coyote
# vague kettle If your layer has the shooting variants, then you would set weight to 1 when you...

heres the code for this:

private IEnumerator MoveShoot() {
        animator.SetLayerWeight (1,1);
        newProjectile = Instantiate(bulletPrefab,firePoint.position,firePoint.rotation);
        yield return new WaitForSeconds(1.5f);
        animator.SetLayerWeight (1,0);
        animator.SetLayerWeight (0,1);
     }

suppose i stop repeatedly pressing the key, how can i properly and smoothly reverse the animation back to the non shooting animation

#

because when i keep pressing the shoot key

#

first time its fine

#

but it keeps turning on and off

vague kettle
#

The delayed method will interrupt the second shot

#

I prefer to use timer variables instead of coroutines because they're much more intuitive to pause and check if they're running

crystal coyote
#

ill take a look at it

#

thank you

crystal coyote
#

@vague kettle:

private void MoveShoot() {
        Debug.Log("Ur shooting while moving!!!");
        timerIsRunning = true;
        seconds = 2;
        animator.SetLayerWeight (1,1);
        newProjectile = Instantiate(bulletPrefab,firePoint.position,firePoint.rotation);
        if (timerIsRunning)
        {
            if (seconds > 0)
            {
                seconds -= Time.deltaTime;
                Debug.Log(seconds);
            }
            else
            {
                Debug.Log("Ur done damn");
                animator.SetLayerWeight(1, 0);
                seconds = 0;
                timerIsRunning = false;
            }
        }
         
     }

everytime this method runs it always gets stuck at 1.996175

#

and this method is called at the update macro

#
if(Input.GetKeyDown(KeyCode.X) && animator.GetFloat("Speed") > 0.01 && animator.GetBool("IsInAir") == false) {
            
            MoveShoot();
            animator.SetTrigger("isShootingMoving");
            
        }      
crystal coyote
#

no matter what i do, it doesnt actually get to zero

crystal coyote
#

correction

#

the timer only decreases when the method is called