Exemplo n.º 1
0
 public void OnDrawGizmos()
 {
     if (!Application.isPlaying)
     {
         aiDriver = gameObject.transform.parent.GetComponent <GameVehicleAIDriver>() as GameVehicleAIDriver;
         if (aiDriver != null)
         {
             if (aiDriver.useObstacleAvoidance)
             {
                 Gizmos.color = Color.green;
                 Gizmos.DrawWireSphere(gameObject.transform.position, 0.1f);
             }
         }
         else
         {
             aiDriverController =
                 gameObject.transform.parent.GetComponent <GameVehicleAIDriverController>() as GameVehicleAIDriverController;
             if (aiDriverController != null)
             {
                 if (aiDriverController.useObstacleAvoidance)
                 {
                     Gizmos.color = Color.cyan;
                     Gizmos.DrawWireSphere(gameObject.transform.position, 0.1f);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
    void Start()
    {
        //wir machen dies in der Start-Routine, weil wir im GameVehicleAIDriver-Skript erst in der Awake-Fkt die Waypoints zuweisen
        //Um sicherzugehen, dass die Waypoints auch gefunden und der List zugewiesen wurde, weisen wir dies deshalb erst hier zu!

        aiDriver = gameObject.GetComponent <GameVehicleAIDriver>();
        if (aiDriver != null)
        {
            waypoints = aiDriver.waypoints;
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        if (!Application.isPlaying)
        {
            aiDriver = gameObject.GetComponent("GameVehicleAIDriver") as GameVehicleAIDriver;

            if (aiDriver != null)
            {
                Transform colliderBottom = transform.Find("Colliders/ColliderBottom");
                aiDriver.oASideOffset = Mathf.Abs(colliderBottom.localPosition.x) + colliderBottom.localScale.x / 2 + 0.1f;
                Vector3 vpPos = aiDriver.viewPoint.localPosition;
                vpPos.z = colliderBottom.localPosition.z + colliderBottom.localScale.z / 2 + 0.1f;
                vpPos.x = 0;
                aiDriver.viewPoint.localPosition = vpPos;
            }
        }
    }
Exemplo n.º 4
0
    public void OnDrawGizmos()
    {
        if (!Application.isPlaying || show)
        {
            aiDriver = gameObject.GetComponent("GameVehicleAIDriver") as GameVehicleAIDriver;

            if (aiDriver != null)
            {
                if (aiDriver.useObstacleAvoidance)
                {
                    Vector3 viewPointLeft;
                    Vector3 viewPointRight;
                    Vector3 forwardDirection = aiDriver.viewPoint.TransformDirection(Vector3.forward * aiDriver.oADistance);

                    Vector3 centerPointL = transform.position + transform.TransformDirection(Vector3.left * aiDriver.oASideOffset);
                    centerPointL.y = aiDriver.viewPoint.position.y;

                    Vector3 centerPointR = transform.position + transform.TransformDirection(Vector3.right * aiDriver.oASideOffset);
                    centerPointR.y = aiDriver.viewPoint.position.y;

                    viewPointLeft   = aiDriver.viewPoint.transform.position;
                    viewPointRight  = aiDriver.viewPoint.transform.position;
                    viewPointLeft  += aiDriver.viewPoint.TransformDirection((Vector3.right * aiDriver.flWheel.localPosition.x));
                    viewPointRight += aiDriver.viewPoint.TransformDirection((Vector3.right * aiDriver.frWheel.localPosition.x));
                    float obstacleAvoidanceWidth = aiDriver.oAWidth;

                    Vector3 leftDirection  = aiDriver.viewPoint.TransformDirection((Vector3.left * obstacleAvoidanceWidth) + (Vector3.forward * aiDriver.oADistance));
                    Vector3 rightDirection = aiDriver.viewPoint.TransformDirection((Vector3.right * obstacleAvoidanceWidth) + (Vector3.forward * aiDriver.oADistance));

                    Vector3 leftSide  = aiDriver.viewPoint.TransformDirection(Vector3.left * aiDriver.oASideDistance);
                    Vector3 rightSide = aiDriver.viewPoint.TransformDirection(Vector3.right * aiDriver.oASideDistance);

                    Debug.DrawRay(viewPointLeft, leftDirection, Color.cyan);
                    Debug.DrawRay(viewPointRight, rightDirection, Color.cyan);
                    Debug.DrawRay(aiDriver.viewPoint.position, forwardDirection, Color.green);
                    Debug.DrawRay(viewPointLeft, forwardDirection, Color.green);
                    Debug.DrawRay(viewPointRight, forwardDirection, Color.green);
                    Debug.DrawRay(centerPointL, leftSide, Color.magenta);
                    Debug.DrawRay(centerPointR, rightSide, Color.magenta);
                }
            }
        }
    }