Esempio n. 1
0
    void FixedUpdate()
    {
        if (v_direction == 4 && selected_flg == true)
        {
            animator.speed      = 1.0f;
            this.rb.constraints = RigidbodyConstraints2D.None;
            this.rb.constraints = RigidbodyConstraints2D.FreezeRotation;
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                v_direction = 0;
                animator.SetFloat("x", 1);
                animator.SetFloat("y", 0);
                count_script.CountAdd();
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                v_direction = 1;
                animator.SetFloat("x", 0);
                animator.SetFloat("y", 1);
                count_script.CountAdd();
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                v_direction = 2;
                animator.SetFloat("x", -1);
                animator.SetFloat("y", 0);
                count_script.CountAdd();
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                v_direction = 3;
                animator.SetFloat("x", 0);
                animator.SetFloat("y", -1);
                count_script.CountAdd();
            }

            //    Debug.Log(v_direction);
        }
        else if (v_direction == 4 && selected_flg == false)
        {
            animator.speed      = 0.0f;
            this.rb.constraints = RigidbodyConstraints2D.FreezePosition;
        }


        //キャラ移動
        rb.velocity = new Vector2(v_x[v_direction] * moveSpeed, v_y[v_direction] * moveSpeed);
    }