示例#1
0
    // Update is called once per frame
    // makes it so that the teleport spheres will activate on trigger
    void OnTriggerEnter(Collider collider)
    {
        Debug.Log("entred on trigger");
        //will only activate if the object is the bot that is using A*
        if (collider.gameObject.name == "bot" && coolDown <= 0)
        {
            Debug.Log("collided");
            //identifies objects that fall under the Teleporters catergory
            foreach (Teleporters spot in FindObjectsOfType <Teleporters>())
            {
                //uses a code number to match teleporters together, and makes sure that it isn't referencing itself
                if (spot.code == code && spot != this)
                {
                    Debug.Log("is this true!");
                    //cooldown time is used to make sure the bot is not constantly teleporting
                    //below that is the actual movement of the object in the teleporter
                    spot.coolDown = 3;
                    Vector3 position = spot.gameObject.transform.position;
                    collider.gameObject.transform.position = position;

                    if (canTravel)
                    {
                        clip.Play();
                        Debug.Log("can travel was true");
                        AddPath.newTarger = AddPath.target;
                        AddPath.AstarPathFinding(AddPath.Findingbot.position, NewTarget.position);
                        canTravel = false;
                        break;
                    }

                    //add code to genrate new path to goal
                    //set bool has been transported to true
                    //move it
                }
            }
        }
    }