// public void Animate(); public void AssesSituation() { if (leader != null) { if (Vector3.Distance(NpcController.Location, leader.Location) >= 1.5f) //Am I going somewhere { movement = (leader.Location - NpcController.Location).normalized; NpcController.Animate(movement, 1f); //agent.destination = target.position; NpcController.mover.MoveTo(leader.Location); } else { NpcController.Animate(movement, 0f); } } }
// public void Animate(); public void AssesSituation() { if (targetEnemy != null) { if (Vector3.Distance(NpcController.Location, targetEnemy.Location) > 1.25f) //Am I going somewhere { movement = (targetEnemy.Location - NpcController.Location).normalized; NpcController.Animate(movement, 1f); NpcController.mover.MoveTo(targetEnemy.Location); } else { Vector3 enemyVector = targetEnemy.Location - NpcController.Location; if (Vector3.Dot(enemyVector, movement) > 0) //am I facing the enemy { NpcController.Attack(enemyVector); } NpcController.Animate(movement, 0f); } } }
void RunToSafety() { if (safeSpaces.Count > 0) { safeHouse = NpcBase.TargetNearest <Safety>(NpcController.Location, safeSpaces).transform; } if (safeHouse != null) { movement = (safeHouse.position - NpcController.Location).normalized; NpcController.Animate(movement, 1f); NpcController.mover.MoveTo(safeHouse.position); bMovingToSafety = true; } }