コード例 #1
0
ファイル: CarAI.cs プロジェクト: EllieGoyer/Black-Ice-Racing
    private void ManageBoosting()
    {
        float angle1 = GetNodeAngle(currentNode);
        float angle2 = Vector3.Angle(transform.forward, nodes[currentNode].position - transform.position);

        int previousNode;

        if (currentNode == 0)
        {
            previousNode = nodes.Count - 1;
        }
        else
        {
            previousNode = currentNode - 1;
        }

        if (angle1 < 20 && angle2 < 10 &&
            Vector3.Distance(transform.position, nodes[currentNode].position) > Vector3.Distance(nodes[previousNode].position, nodes[currentNode].position) / 2 &&
            controller.boostCharge > 0)
        {
            isBoosting            = true;
            controller.boostInput = true;
            controller.Boost();
            Debug.Log("Boosting");
        }
        else
        {
            isBoosting            = false;
            controller.boostInput = false;
        }
    }