Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        manageCollision();
        manageTools();

        // WITH POSITION
        if (Input.GetAxis("Horizontal") < 0)
        {
            charac_anim.SetBool("run_left", true);
            charac_anim.SetBool("run_right", false);
            charac_anim.SetBool("idle", false);
            charac_anim.SetBool("fly", false);
        }
        else if (Input.GetAxis("Horizontal") > 0)
        {
            charac_anim.SetBool("run_right", true);
            charac_anim.SetBool("run_left", false);
            charac_anim.SetBool("idle", false);
            charac_anim.SetBool("fly", false);
        }
        else
        {
            charac_anim.SetBool("fly", true);
            charac_anim.SetBool("idle", false);
            charac_anim.SetBool("run_left", false);
            charac_anim.SetBool("run_right", false);
            if (onGround || onBreakable)
            {
                charac_anim.SetBool("idle", true);
                charac_anim.SetBool("fly", false);
            }
        }
        Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);

        transform.position += movement * Time.deltaTime * speed;

        if (Input.GetKey(KeyCode.Escape))
        {
            panel.gameObject.SetActive(true);
            panel.PauseGame();
        }
        // WITH A FORCE

        /*
         * x_movement = Input.GetAxis("Horizontal");
         *
         * if (rb.velocity.magnitude < max_speed)
         * {
         *  Vector2 movement = new Vector2(x_movement, 0);
         *  rb.AddForce(movement_scalar * movement);
         * }
         */


        // WITH VELOCITY

        /*
         * if (Input.GetKey(KeyCode.RightArrow))
         *  rb.velocity = new Vector2(speed, rb.velocity.y);
         * if (Input.GetKey(KeyCode.LeftArrow))
         *  rb.velocity = new Vector2(-speed, rb.velocity.y);
         */
    }
Exemplo n.º 2
0
 public void PauseGame()
 {
     inGameMenu.PauseGame();
 }