Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_notifiedHit.isHit())
        {
            return;
        }
        else
        {
            GetComponent <Rigidbody>().isKinematic = true;
        }

        //timer += Time.deltaTime;


        //DirectionFix();
        //transform.position += m_direction * m_speed * Time.deltaTime;

        m_direction = m_targetPosition - transform.position;

        if (m_direction.magnitude < 1.0f)
        {
            newRanTargetLocation();
        }

        m_direction.Normalize();
        transform.position += m_direction * m_speed * Time.deltaTime;

        transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(m_direction, Vector3.up), Time.deltaTime * m_RotResponse);
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (m_notifiedHit.isHit())
        {
            return;
        }

        m_ForceAdditional = Vector3.zero;

        if (m_Attacking)
        {
            m_attackTime += Time.deltaTime;

            /*
             * if (Input.GetButtonDown("Fire1") && !m_animator.GetBool("AttackAgain"))
             * {
             *  m_animator.SetBool("AttackAgain", true);
             *  m_attackTime = Mathf.Min(m_attackTime, 0.40f);
             * }
             *
             * if (m_animator.GetBool("AttackAgain") && m_attackTime > 0.50f && m_attackTime < 0.58f)
             * {
             *  m_hitbox.activate();
             * }
             */
            if (m_attackTime > 1.0f)
            {
                m_attackTime = 0.0f;
                m_Attacking  = false;
                m_hitbox.deactivate();
            }
            else
            {
                m_Force = Vector3.zero;
                return;
            }
        }

        if (m_Dashing)
        {
            m_DashTime += Time.deltaTime;

            if (m_DashTime > 0.5f)
            {
                m_DashTime = 0.0f;
                m_Dashing  = false;
            }
        }

        float ForwardAxis    = Input.GetAxis("Vertical");
        float HorizontalAxis = Input.GetAxis("Horizontal");

        m_Force = (transform.forward * m_walkAccel * Time.deltaTime) * ForwardAxis;

        float RT = Input.GetAxis("Target");

        if (RT > 0.5f)
        {
            m_Force += (transform.right * m_walkAccel * Time.deltaTime) * HorizontalAxis;
        }
        else
        {
            Quaternion rotation = m_rigidbody.rotation;
            rotation             = Quaternion.Euler(0.0f, m_rigidbody.rotation.eulerAngles.y + (230.0f * (Mathf.Clamp(HorizontalAxis, -0.5f, 0.5f))), 0.0f);
            m_rigidbody.rotation = Quaternion.Lerp(m_rigidbody.rotation, rotation, Time.deltaTime);
        }


        if (Input.GetButtonDown("Fire1"))
        {
            m_animator.SetBool("AttackAgain", false);
            m_animator.SetTrigger("Attack");
            m_Attacking = true;
            m_hitbox.activate();
        }

        if (Input.GetButtonDown("Fire3") && !m_Dashing)
        {
            Vector3 direction = new Vector3(HorizontalAxis, 0.0f, ForwardAxis);
            m_ForceAdditional += direction.normalized * m_dashPower;
            m_ForceAdditional += Vector3.up * 4.0f;

            m_Dashing = true;
        }

        /*
         * if (Input.GetButton("Fire2"))
         * {
         *  m_animator.SetBool("Blocking", true);
         * }
         * else
         * {
         *  m_animator.SetBool("Blocking", false);
         * }
         */
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        if (m_target && m_target.gameObject.tag != "BBSEnd")
        {
            m_target = null;
        }

        if (m_target == null)
        {
            GetComponent <Rigidbody>().isKinematic = false;
            GetComponent <Rigidbody>().useGravity  = true;

            GetComponent <Rigidbody>().freezeRotation = false;

            GameObject toBreak = null;

            foreach (Transform tr in GetComponentsInChildren <Transform>())
            {
                if (tr.gameObject.tag == "BBSEnd")
                {
                    toBreak     = tr.gameObject;
                    toBreak.tag = "Untagged";
                    break;
                }
            }

            Vector3 deathKnockback = new Vector3(Random.Range(-1, 1), Random.Range(-1, 1), Random.Range(-1, 1));
            deathKnockback.Normalize();

            deathKnockback *= 20;

            GetComponent <Rigidbody>().AddForce(deathKnockback, ForceMode.Impulse);

            Destroy(this);
            return;
        }

        spawnBullet();

        if (m_notifiedHit.isHit())
        {
            GetComponent <Rigidbody>().isKinematic = false;
            return;
        }
        else
        {
            GetComponent <Rigidbody>().isKinematic = true;
        }

        if (m_target)
        {
            if ((m_target.transform.position - transform.position).magnitude > m_minDistance)
            {
                transform.position = Vector3.Lerp(transform.position, m_target.transform.position, Time.deltaTime * m_response);
            }


            Vector3 targetDir = transform.position - m_lookTo.transform.position;

            float   step   = 3 * Time.deltaTime;
            Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0F);
            Debug.DrawRay(transform.position, newDir, Color.red);
            transform.rotation = Quaternion.LookRotation(newDir);

            //transform.LookAt(m_target.transform);
        }
    }