public void OnDisable() { steering.enabled = true; aicTRl.enabled = true; simpleLoc.enabled = true; if (aicTRl.hp == 0 && !aicTRl.dead) { aicTRl.HandleDeath(); } }
public void Update() { float delta = Time.deltaTime * speed; transform.Translate(dir * delta); RaycastHit hit; if (Physics.Raycast(transform.position, -dir, out hit, delta) && hit.transform.name != friendly) { Destroy(gameObject); AIControl ai = hit.transform.GetComponent <AIControl>(); Module telporter = hit.transform.GetComponent <Module>(); if (telporter != null) { telporter.TryCancelTeleport(); return; } if (ai != null && ai.hp == 0 && !ai.dead) { ai.dead = true; ai.HandleDeath(); return; } if (ai != null && ai.hp > 0) { ai.hp--; Pusher pusher = ai.transform.GetComponent <Pusher>(); Lunge lunge = ai.transform.GetComponent <Lunge>(); if (!lunge.enabled && !pusher.enabled) { pusher.pushDir = dir; pusher.enabled = true; } Instantiate(gore, hit.point, Quaternion.identity); } } }