Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (!alive)
        {
            return;
        }

        if (enemyAnimation.attacking || stopped)
        {
            Stop();
            return;
        }

        Vector3 dest       = PlayerCoordinator.Instance.player.transform.position;
        float   currentVel = agent.velocity.magnitude;

        if (lastVel - 0.1 > currentVel)
        {
            //Stop enemy from sliding, if it is desaccelerating, set its velocitry to 0
            Stop();
            lastVel = 0;
        }
        else
        {
            lastVel = currentVel;
        }

        if (!hasTarget)
        {
            agent.SetDestination(dest);
            CDUtils.Delay(200, () => { hasTarget = false; });
        }
        transform.LookAt(dest);
    }
 private void jump()
 {
     rbody.AddForce(transform.up * jumpForce, ForceMode.Impulse);
     jumpCD = true;
     CDUtils.Delay(100, () => { jumpCD = false; });
 }