Exemple #1
0
 public void PlayAnimation()
 {
     foreach (var animator in characterCustomization.GetAnimators())
     {
         animator.SetBool("walk", true);
     }
 }
Exemple #2
0
        public void PlayAnim()
        {
            walk_active = !walk_active;

            foreach (Animator a in characterCustomization.GetAnimators())
            {
                a.SetBool("walk", walk_active);
            }

            playbutton_text.text = (walk_active) ? "STOP" : "PLAY";
        }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (controller.isGrounded)
        {
            /*
             * if (Input.GetKey(KeyCode.Space))
             * {
             *  foreach (Animator a in CharacterCustomization.GetAnimators())
             *      a.SetInteger("condition", 0);
             *
             *
             *  if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
             *  {
             *      moveDir = new Vector3(-3, 5, 0);
             *  }
             *  if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
             *  {
             *      moveDir = new Vector3(3, 5, 0);
             *  }
             *  if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
             *  {
             *      moveDir = new Vector3(0, 5, 3);
             *  }
             *  if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
             *  {
             *      moveDir = new Vector3(0, 5, -3);
             *  }
             *  else
             *  {
             *      // moveDir = new Vector3(0, 5, 0);
             *  }
             *
             *
             *
             * }
             *
             * else if (Input.GetKeyUp(KeyCode.Space))
             * {
             *  moveDir = new Vector3(0, -5, 0);
             * }
             */
            if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 1);
                }
                moveDir  = new Vector3(0, 0, 1);
                moveDir *= speed;
                transform.eulerAngles = new Vector3(0, 0, 0);
            }
            else if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.W))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 0);
                }
                moveDir = new Vector3(0, 0, 0);
            }
            else if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 1);
                }
                moveDir  = new Vector3(0, 0, -1);
                moveDir *= speed;
                transform.eulerAngles = new Vector3(0, 180, 0);
            }
            else if (Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.S))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 0);
                }
                moveDir = new Vector3(0, 0, 0);
            }
            else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 1);
                }
                moveDir  = new Vector3(1, 0, 0);
                moveDir *= speed;
                transform.eulerAngles = new Vector3(0, 90, 0);
            }
            else if (Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.D))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 0);
                }
                moveDir = new Vector3(0, 0, 0);
            }
            else if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 1);
                }
                moveDir  = new Vector3(-1, 0, 0);
                moveDir *= speed;
                transform.eulerAngles = new Vector3(0, 270, 0);
            }
            else if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.A))
            {
                foreach (Animator a in CharacterCustomization.GetAnimators())
                {
                    a.SetInteger("condition", 0);
                }

                moveDir = new Vector3(0, 0, 0);
            }
        }
        moveDir.y -= gravity * Time.deltaTime;
        controller.Move(moveDir * Time.deltaTime);
    }