void Update()
 {
     if (Input.GetKey(KeyCode.D))
     {
         transform.localRotation = Quaternion.Euler(0, 0, 0);
         animator.Play(Anims.Run);
     }
     else if (Input.GetKey(KeyCode.S))
     {
         animator.Play(Anims.Roll);
     }
     else if (Input.GetKey(KeyCode.Q))
     {
         transform.localRotation = Quaternion.Euler(0, 180, 0);
         animator.Play(Anims.Run);
     }
     else if (Input.GetKey(KeyCode.Z))
     {
         animator.Play(Anims.Jump);
     }
     else
     {
         animator.Play(Anims.Iddle);
     }
 }
Example #2
0
 void Update()
 {
     if (Input.GetKey(KeyCode.RightArrow))
     {
         transform.localRotation = Quaternion.Euler(0, 0, 0);
         animator.Play(Anims.Run);
     }
     else if (Input.GetKey(KeyCode.DownArrow))
     {
         animator.Play(Anims.Roll);
     }
     else if (Input.GetKey(KeyCode.LeftArrow))
     {
         transform.localRotation = Quaternion.Euler(0, 180, 0);
         animator.Play(Anims.Run);
     }
     else if (Input.GetKey(KeyCode.UpArrow))
     {
         animator.Play(Anims.Jump);
     }
     else
     {
         animator.Play(Anims.Iddle);
     }
 }
Example #3
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector2 vitesse = Vector2.zero;

        if (Input.GetKey(KeyCode.UpArrow) && controls == PlayerControls.ArrowAnd0 ||
            Input.GetKey(KeyCode.Z) && controls == PlayerControls.ZQSDF)
        {
            vitesse += Vector2.up;
        }

        if (Input.GetKey(KeyCode.DownArrow) && controls == PlayerControls.ArrowAnd0 ||
            Input.GetKey(KeyCode.S) && controls == PlayerControls.ZQSDF)
        {
            vitesse += Vector2.down;
        }

        if (Input.GetKey(KeyCode.LeftArrow) && controls == PlayerControls.ArrowAnd0 ||
            Input.GetKey(KeyCode.Q) && controls == PlayerControls.ZQSDF)
        {
            vitesse += Vector2.left;
            spriteRenderer.flipX = true;
        }

        if (Input.GetKey(KeyCode.RightArrow) && controls == PlayerControls.ArrowAnd0 ||
            Input.GetKey(KeyCode.D) && controls == PlayerControls.ZQSDF)
        {
            vitesse += Vector2.right;
            spriteRenderer.flipX = false;
        }

        if ((Input.GetKeyDown(KeyCode.Keypad0) && controls == PlayerControls.ArrowAnd0 ||
             Input.GetKey(KeyCode.F) && controls == PlayerControls.ZQSDF) && rollCooldown <= 0)
        {
            animator.Play(Anims.Roll);
            rollCooldown = rollCooldownDuration;
        }

        if (animator.CurrentAnimation.name != Anims.Roll || animator.LoopCount >= 1)
        {
            if (vitesse.magnitude > 0)
            {
                animator.Play(Anims.Run);
            }
            else
            {
                animator.Play(Anims.Iddle);
            }
        }

        controlLevel  = Mathf.Clamp01(controlLevel + Time.deltaTime * ControlRecoverySpeed);
        body.velocity = Vector2.Lerp(body.velocity, vitesse.normalized * speed, (controlLevel < 0.05f) ? 0.05f : Mathf.Pow(2, 10 * (controlLevel - 1)));
        var emission = DustWalkFX.emission;

        emission.rateOverTime = vitesse.magnitude * DustAmount;

        rollCooldown -= Time.deltaTime;
    }
Example #4
0
 void Update()
 {
     if (Input.GetKey(KeyCode.RightArrow))
     {
         animator.Play(Anims.Run);
     }
     else if (Input.GetKey(KeyCode.DownArrow))
     {
         animator.Play(Anims.Roll);
     }
     else
     {
         animator.Play(Anims.Iddle);
     }
 }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        Vector3 move = Vector3.zero;

        if (Input.GetKey(KeyCode.UpArrow))
        {
            move += Vector3.up;
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            move += Vector3.down;
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            move += Vector3.left;
            spriteRenderer.flipX = true;
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            move += Vector3.right;
            spriteRenderer.flipX = false;
        }
        if (Input.GetKeyDown(KeyCode.Space) && rollCooldown <= 0)
        {
            animator.Play(Anims.Roll);
            rollCooldown = rollCooldownDuration;
        }
        if (animator.CurrentAnimation != Anims.Roll || animator.LoopCount >= 1)
        {
            if (move.magnitude > 0)
            {
                animator.Play(Anims.Run);
            }
            else
            {
                animator.Play(Anims.Iddle);
            }
        }

        this.transform.position = this.transform.position + speed * Time.deltaTime * move.normalized;
        rollCooldown           -= Time.deltaTime;
    }
Example #6
0
    void FixedUpdate()
    {
        bool    moved = false;
        Vector3 move  = Vector3.zero;

        if (p2)
        {
            if (Input.GetKey(KeyCode.Space))
            {
                move += this.moveRoll();
                moved = true;
            }
            else
            {
                if (Input.GetKey(KeyCode.RightArrow))
                {
                    move += this.moveRight();
                    moved = true;
                }
                else if (Input.GetKey(KeyCode.LeftArrow))
                {
                    move += this.moveLeft();
                    moved = true;
                }
                if (Input.GetKey(KeyCode.UpArrow))
                {
                    move += this.moveUp();
                    moved = true;
                }
                else if (Input.GetKey(KeyCode.DownArrow))
                {
                    move += this.moveDown();
                    moved = true;
                }
            }
        }
        else
        {
            if (Input.GetKey(KeyCode.E))
            {
                move += this.moveRoll();
                moved = true;
            }
            else
            {
                if (Input.GetKey(KeyCode.D))
                {
                    move += this.moveRight();
                    moved = true;
                }
                else if (Input.GetKey(KeyCode.Q))
                {
                    move += this.moveLeft();
                    moved = true;
                }
                if (Input.GetKey(KeyCode.Z))
                {
                    move += this.moveUp();
                    moved = true;
                }
                else if (Input.GetKey(KeyCode.S))
                {
                    move += this.moveDown();
                    moved = true;
                }
            }
        }

        if (!moved)
        {
            animator.Play(Anims.Iddle);
            moved = false;
        }

        rigidbody2D.velocity = move;
    }