修正森林圖無法觸發輔助問題
This commit is contained in:
1 parent
062dd0f9d5
commit
285a4e1e1e
18 files changed
+151
-44
No files matched your search
@@ -31,9 +31,24 @@ public class BotSpawner : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 拖進來的是 prefab 檔案本身 (不在場景裡) 或沒拖 : 改用場景裡的玩家 (只有玩家身上有 PlayerLook)
|
||||
if (player == null || !player.gameObject.scene.IsValid())
|
||||
{
|
||||
PlayerLook look = FindAnyObjectByType<PlayerLook>();
|
||||
player = look != null ? look.transform.root : null;
|
||||
}
|
||||
|
||||
Spawn();
|
||||
}
|
||||
|
||||
// 給其他腳本找場景裡的 BotSpawner : 沒拖、或拖進來的是 prefab 檔案本身 (不在場景裡) 都改用場景裡的那一個
|
||||
// prefab 存不住場景物件的參照,而且 Inspector 很容易不小心拖到 Project 視窗裡的 prefab
|
||||
public static BotSpawner FindInScene(BotSpawner assigned)
|
||||
{
|
||||
if (assigned != null && assigned.gameObject.scene.IsValid()) return assigned;
|
||||
return FindAnyObjectByType<BotSpawner>();
|
||||
}
|
||||
|
||||
void Spawn()
|
||||
{
|
||||
if (botPrefab == null) return;
|
||||
|
||||
Reference in new issue
Block a user