private void OnTriggerStay(Collider other) { if (other != null) { if (other.name.Contains("Hero")) { isInFight = true; if (actHP <= 0) { other.gameObject.GetComponent <Hero>().isInFight = false; MoneyManagement.DropMoney(moneydropped); Destroy(this.gameObject); } } } }
// Update is called once per frame void Update() { // All das hier muss im Update stehen #region Set Color if (isInFightWithTower || isInFight) { this.gameObject.GetComponent <Renderer>().material.color = Color.red; } else { this.gameObject.GetComponent <Renderer>().material.color = standard_color; } #endregion #region Set Stop in Fight if (isInFight) { movementstep = 0; } else { movementstep = speed * Time.deltaTime * 2; } #endregion if (GameManager.isDead) { Destroy(this.gameObject); } #region Check for Next Waypoint and Move // MoneyDrop and die if (targetWaypoint != null || this != null) { float dist = Vector3.Distance(this.transform.position, targetWaypoint.position); CheckDistance(dist); } this.transform.position = Vector3.MoveTowards(this.transform.position, targetWaypoint.position, movementstep); if (actHP <= 0) { MoneyManagement.DropMoney(moneydropped); Destroy(this.gameObject); } #endregion }