Exemplo n.º 1
0
    // AI METHODS
    void ComputerMove()
    {
        // Perhaps reduce the speed
        Vector3 nMovement = AI.GetCurrentHeading() * AI.GetCurrentSpeed();
//		Debug.Log("Computer Moving... x:" + nMovement.x.ToString() + " y: " + nMovement.y.ToString());
        Vector3 pos = transform.position;

        pos.z = Mathf.Clamp(transform.position.z, 0, 0);
        transform.position = pos;

        if (playerManager.IsAlive())
        {
            rb.velocity = FitToBounds(transform.position, nMovement);
        }

        for (int i = 0; i < bodyParts.Count; i++)
        {
            if (bodyParts [i].rb.velocity.magnitude > rb.velocity.magnitude)
            {
                Vector3 CurrentVelocity = bodyParts [i].rb.velocity.normalized;
                CurrentVelocity          *= rb.velocity.magnitude;
                bodyParts [i].rb.velocity = CurrentVelocity;
            }
        }
    }