Пример #1
0
 // Update is called once per frame
 void Update()
 {
     transform.Translate(new Vector3(HybridInput.GetAxis("Horizontal"), HybridInput.GetAxis("Vertical"), 0f) * Time.deltaTime);
     if (HybridInput.GetButton("Button"))
     {
         r.color = new Color(0, 0, 0);
     }
     else
     {
         r.color = new Color(1, 1, 1);
     }
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (Alive)
        {
            InputX = HybridInput.GetAxis("Horizontal");
            InputY = HybridInput.GetAxis("Vertical");

            var input = new Vector3(InputX, 0.0f, InputY);

            if (Hunger > 0.0f)
            {
                Hunger -= Time.deltaTime * HungerDecayRate;
            }
            else
            {
                Die();
            }
            float bodyScale = Hunger / 100f + 0.1f;
            Body.localScale = new Vector3(bodyScale, bodyScale, bodyScale);

            var horizSpeed = input;
            horizSpeed.y = 0.0f;

            if (horizSpeed.magnitude > 0.1f)
            {
                var   horizDiff = Vector3.SignedAngle(Model.forward, horizSpeed, Vector3.up);
                float amount    = Mathf.Sign(horizDiff) * Mathf.Min(Mathf.Abs(horizDiff), TurnSpeed * Time.deltaTime);
                Model.Rotate(Vector3.up, amount);
                anim.SetFloat("LegSpeed", Mathf.Clamp(horizSpeed.magnitude, 0.0f, 1.0f));

                if (footStepTimer < Time.time)
                {
                    PlayRandomSound(footSteps);
                    footStepTimer = Time.time + 0.15f + Random.Range(0.0f, 0.1f);
                }
            }
            else
            {
                anim.SetFloat("LegSpeed", 0.0f);
            }
        }
    }