Пример #1
0
    //on collision with object
    void OnTriggerEnter2D(Collider2D respawn)
    {
        //post to debug
        Debug.Log("respawn collider hit");

        //if the object is the player(s)
        if (respawn.gameObject.name == "player 1")
        {
            //fin the gameobject called MAN (can be changed in final Vesion)
            GameObject goOne = GameObject.Find("player 1");
            //finf the scrips called characterController (changed in final version)
            playerOne callrespawnOne = (playerOne)goOne.GetComponent(typeof(playerOne));
            //in found script call the method called respawn
            callrespawnOne.setDeadOne();
        }
        //if the object is the player(s)
        if (respawn.gameObject.name == "player 2")
        {
            //fin the gameobject called MAN (can be changed in final Vesion)
            GameObject goTwo = GameObject.Find("player 2");
            //finf the scrips called characterController (changed in final version)
            playerTwo callrespawnTwo = (playerTwo)goTwo.GetComponent(typeof(playerTwo));
            //in found script call the method called respawn
            callrespawnTwo.setDeadTwo();
        }
    }
Пример #2
0
    //on collision with object
    void OnTriggerEnter2D(Collider2D checkpoint)
    {
        //if the object is the player(s)
        if (checkpoint.gameObject.tag == "Player" && ranGenDone == false)
        {
            //post to debug
            Debug.Log("checkpoint collider hit");

            //fin the gameobject with tag player
            GameObject goone = GameObject.Find("player 1");
            //finf the scrips called playerOne
            playerOne callcheckpointone = (playerOne)goone.GetComponentInChildren(typeof(playerOne));
            //in found script call the method called respawn
            callcheckpointone.checkpointOne();
            callcheckpointone.setSpawnedOne();

            //fin the gameobject with tag player
            GameObject gotwo = GameObject.Find("player 2");
            //finf the scrips called playerTwo
            playerTwo callcheckpointtwo = (playerTwo)gotwo.GetComponentInChildren(typeof(playerTwo));
            //in found script call the method called respawn
            callcheckpointtwo.checkpointTwo();
            callcheckpointtwo.setSpawnedTwo();

            //fin the gameobject called ran tile gen
            GameObject tile = GameObject.Find("ran tile gen");
            //finf the scrips called rantilegen
            rantilegen callgentile = (rantilegen)tile.GetComponent(typeof(rantilegen));
            //in found script call the method called respawn
            callgentile.spawntiles();

            ranGenDone = true;
        }
    }