private void Update()
    {
        if (Input.GetButtonUp("Cancel"))
        {
            PlayerPrefs.SetFloat("PlayerXPos", transform.position.x);
            PlayerPrefs.SetFloat("PlayerZPos", transform.position.z);
            SceneManager.LoadScene("Menu");
        }
        Vector3 newSpeed = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * Speed;

        if (newSpeed.magnitude >= 0.1f)
        {
            Model.transform.LookAt(Model.transform.position + newSpeed);
            rigidbody.velocity   = newSpeed;
            IdleAnimation.Active = false;
            if (!WalkAnimation.Active)
            {
                WalkAnimation.StartAnimations(true);
            }
        }
        else
        {
            rigidbody.velocity   = Vector3.zero;
            WalkAnimation.Active = false;
            if (!IdleAnimation.Active)
            {
                IdleAnimation.StartAnimations(true);
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetAxis("Horizontal") == 0)
     {
         animation.Active = false;
         idle.StartAnimations();
     }
     else if (Input.GetAxis("Horizontal") > 0)
     {
         idle.Active = false;
         animation.StartAnimations();
         //gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, 0.5f);
         gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
     }
     else if (Input.GetAxis("Horizontal") < 0)
     {
         idle.Active = false;
         animation.StartAnimations();
         //gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, -0.5f);
         gameObject.transform.localEulerAngles = new Vector3(0, 180, 0);
     }
 }
Esempio n. 3
0
 public void Launch(BattleStats attacker, BattleStats defender)
 {
     CurrentAttack = this;
     this.attacker = attacker;
     this.defender = defender;
     attacker.IdleAnimation.Active = false;
     attacker.Energy -= EnergyCost;
     if (!Game.IsHuman || attacker.IsPlayer)
     {
         AttackAnimation.Main = attacker.gameObject;
         AttackAnimation.Start();
         AttackAnimation.StartAnimations();
     }
     else
     {
         HumanAnimation.Main = attacker.gameObject;
         HumanAnimation.Start();
         HumanAnimation.StartAnimations();
     }
 }