Exemple #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);
                 }
             }
         }
     }
 }
Exemple #2
0
    void Update()
    {
        if (!Application.isPlaying)
        {
            aiDriverController = gameObject.GetComponent("GameVehicleAIDriverController") as GameVehicleAIDriverController;

            if (aiDriverController != null)
            {
                Transform colliderBottom = transform.Find("Colliders/ColliderBottom");

                if (colliderBottom != null)
                {
                    aiDriverController.oASideOffset = Mathf.Abs(colliderBottom.localPosition.x) + colliderBottom.localScale.x / 2 + 0.1f;

                    if (aiDriverController.viewPoint != null)
                    {
                        Vector3 vpPos = aiDriverController.viewPoint.localPosition;
                        vpPos.z = colliderBottom.localPosition.z + colliderBottom.localScale.z / 2 + 0.1f;
                        vpPos.x = 0;
                        aiDriverController.viewPoint.localPosition = vpPos;
                    }
                }
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (useTrigger)
        {
            GameVehicleAIWaypointEditor aiWaypointEditor;
            aiWaypointEditor = other.gameObject.transform.root.gameObject.GetComponentInChildren <GameVehicleAIWaypointEditor>();

            if (aiWaypointEditor != null)
            {
                if (aiWaypointEditor.folderName == gameObject.transform.parent.name)
                {
                    GameVehicleAIDriverController aIDriverController = other.gameObject.transform.root.gameObject.GetComponentInChildren <GameVehicleAIDriverController>();

                    if (aIDriverController != null)
                    {
                        if (aIDriverController.waypoints.Count > aIDriverController.currentWaypoint)   //2011-12-26
                        {
                            if (aIDriverController.waypoints[aIDriverController.currentWaypoint].gameObject.name == gameObject.name)
                            {
                                aIDriverController.NextWaypoint();
                            }
                        }
                    }
                }
            }
        }
    }
    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!

        aiDriverControllerScript = gameObject.GetComponent("GameVehicleAIDriverController") as GameVehicleAIDriverController;
        waypoints = aiDriverControllerScript.waypoints;
    }
 void OnTriggerEnter(Collider other)
 {
     //if (other.gameObject.transform.root.gameObject.tag == tagName) //2013-08-02
     if (other.gameObject.transform.root.gameObject.CompareTag(tagName))   //2013-08-02
     {
         GameVehicleAIDriverController aIDriverController = other.gameObject.transform.root.gameObject.GetComponentInChildren <GameVehicleAIDriverController>();
         if (aIDriverController != null)
         {
             aIDriverController.SetNewWaypointSet(folderName, preName, maxSpeed, nextWaypointNo);
         }
     }
 }
Exemple #6
0
    //2012-06-23

    void OnTriggerEnter(Collider other)
    {
        //if (other.gameObject.transform.root.gameObject.tag == tagName)    //2013-08-02
        if (other.gameObject.transform.root.gameObject.CompareTag(tagName))   //2013-08-02
        {
            GameVehicleAIDriverController aIDriverController =
                other.gameObject.transform.root.gameObject.GetComponentInChildren <GameVehicleAIDriverController>();
            if (aIDriverController != null)
            {
                //aIDriverController.useObstacleAvoidance = switchUseOaTo;
                aIDriverController.SwitchOaMode(switchUseOaTo);
            }
        }
    }
Exemple #7
0
    public void OnDrawGizmos()
    {
        if (!Application.isPlaying || show)
        {
            aiDriverController = gameObject.GetComponent("GameVehicleAIDriverController") as GameVehicleAIDriverController;

            List <Transform> waypoints = aiDriverController.waypoints;

            Vector3 wpPosLast = Vector3.zero;

            foreach (Transform wp in waypoints)
            {
                if (wpPosLast != Vector3.zero)
                {
                    Debug.DrawRay(wpPosLast, wp.position, color);
                }

                wpPosLast = wp.position;
            }
        }
    }
Exemple #8
0
    public void OnDrawGizmos()
    {
        if (!Application.isPlaying || show)
        {
            aiDriverController = gameObject.GetComponent("GameVehicleAIDriverController") as GameVehicleAIDriverController;
            aIMotorMapping     = gameObject.GetComponent("GameVehicleMotorMapping") as GameVehicleMotorMapping;
            if (aiDriverController.useObstacleAvoidance && aIMotorMapping.flWheelMesh != null)
            {
                Vector3 viewPointLeft;
                Vector3 viewPointRight;

                if (aiDriverController.viewPoint != null)
                {
                    Vector3 forwardDirection = aiDriverController.viewPoint.TransformDirection(Vector3.forward * aiDriverController.oADistance);

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

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

                    viewPointLeft   = aiDriverController.viewPoint.transform.position;
                    viewPointRight  = aiDriverController.viewPoint.transform.position;
                    viewPointLeft  += aiDriverController.viewPoint.TransformDirection((Vector3.right * aIMotorMapping.flWheelMesh.localPosition.x));
                    viewPointRight += aiDriverController.viewPoint.TransformDirection((Vector3.right * aIMotorMapping.frWheelMesh.localPosition.x));
                    float obstacleAvoidanceWidth = aiDriverController.oAWidth;

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

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

                    Debug.DrawRay(viewPointLeft, leftDirection, Color.cyan);
                    Debug.DrawRay(viewPointRight, rightDirection, Color.cyan);
                    Debug.DrawRay(aiDriverController.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);


                    //----------------------------------------
                    //leftFront
                    Vector3 leftFrontSidePos = transform.position + transform.TransformDirection(Vector3.left * aiDriverController.oASideOffset);
                    leftFrontSidePos.y = aiDriverController.viewPoint.position.y;
                    leftFrontSidePos  += transform.TransformDirection(Vector3.forward * aiDriverController.oASideFromMid);
                    Debug.DrawRay(leftFrontSidePos, leftSide, Color.magenta);

                    //leftRear
                    Vector3 leftRearSidePos = transform.position + transform.TransformDirection(Vector3.left * aiDriverController.oASideOffset);
                    leftRearSidePos.y = aiDriverController.viewPoint.position.y;
                    leftRearSidePos  -= transform.TransformDirection(Vector3.forward * aiDriverController.oASideFromMid);
                    Debug.DrawRay(leftRearSidePos, leftSide, Color.magenta);

                    //rightFront
                    Vector3 rightFrontSidePos = transform.position + transform.TransformDirection(Vector3.right * aiDriverController.oASideOffset);
                    rightFrontSidePos.y = aiDriverController.viewPoint.position.y;
                    rightFrontSidePos  += transform.TransformDirection(Vector3.forward * aiDriverController.oASideFromMid);
                    Debug.DrawRay(rightFrontSidePos, rightSide, Color.magenta);

                    //rightRear
                    Vector3 rightRearSidePos = transform.position + transform.TransformDirection(Vector3.right * aiDriverController.oASideOffset);
                    rightRearSidePos.y = aiDriverController.viewPoint.position.y;
                    rightRearSidePos  -= transform.TransformDirection(Vector3.forward * aiDriverController.oASideFromMid);
                    Debug.DrawRay(rightRearSidePos, rightSide, Color.magenta);
                }
            }
        }
    }