Exemplo n.º 1
0
    //摺疊 ctrl+m+o
    //展開 ctrl+m+l

    private void Start()
    {
        ani                  = GetComponent <Animator>();
        nav                  = GetComponent <NavMeshAgent>();
        hpvaluemanger        = GetComponentInChildren <HpValueManger>();
        playerpos            = GameObject.FindWithTag("Player").GetComponent <Transform>();
        nav.stoppingDistance = data.stopdis;
        nav.speed            = data.speed;
        Timer                = data.cd - 0.5f;
        hp = data.hp;
    }
Exemplo n.º 2
0
 private float[] enemydis;       //取得敵人距離
 private void Start()
 {
     rig = GetComponent <Rigidbody>();
     //GameObject.Find("物件名稱").GetComponent<T>();		T --泛型(任一個形式
     joystick      = GameObject.Find("虛擬搖桿").GetComponent <FixedJoystick>();
     ani           = GetComponent <Animator>();
     target        = GameObject.Find("目標").transform;
     levelmanger   = FindObjectOfType <LevelManager>();              //尋找類型  該類型只有一個
     hpvaluemanger = GetComponentInChildren <HpValueManger>();       //尋找在子物件的該類型
     if (SceneManager.GetActiveScene().buildIndex == 1)
     {
         data.Hp = data.maxHp;
     }
 }