Пример #1
0
 // Start is called before the first frame update
 void Start()
 {
     WayPointMap        = EnemySettings.GetWayPoints();
     DeadlyWayPointMap  = EnemySettings.GetSuicideWayPoints();
     transform.position = WayPointMap[WaypointIndex].transform.position; //the initail position is the first index point
     EnemyData          = gameObject.GetComponent <PH_Enemy>();          //script from the same object
     session            = FindObjectOfType <PH_GameSession>();           //game session for this scene
 }
    public void Hit()
    {
        PH_Enemy EnemyScript = gameObject.GetComponent <PH_Enemy>();//check if the object has an enemy script

        if (!EnemyScript)
        {
            Destroy(gameObject);
        }                                         //if it doesn't, just destroy it normally on contact

        else
        {
            EnemyScript.Die();
        }                          //if it is an enemy, use it's 'Die' function.
    }