private void Update() { transform.position = Vector3.MoveTowards(transform.position, Waypoints[CurrentWaypoint].position, speed*Time.deltaTime); if (Vector3.Distance(transform.position,Waypoints[CurrentWaypoint].position)<speed*Time.deltaTime) { CurrentWaypoint++; CurrentWaypoint = CurrentWaypoint % Waypoints.Count; //aritmetica modular vieja Rotator.turnTowards(Waypoints[CurrentWaypoint].position); } if (Time.time>AttackCD+LastAttack) { Debug.Log("entroCD"); if (Mathf.Abs(Player.PlayerSingleton.ExactLeftOrRIght(DropSpot.transform.position.z)) <Prescision ) { Debug.Log("entrohorizontal" + Mathf.Abs(Player.PlayerSingleton.ExactLeftOrRIght(DropSpot.transform.position.z))); if (Player.PlayerSingleton.UpOrDown(DropSpot.transform.position.y) == -1) { Debug.Log("entroVertical"); LastAttack = Time.time; Instantiate(Projectile, DropSpot.position, DropSpot.rotation); } } } }
private void Update() { if (LastPause < Time.time) { transform.position = Vector3.MoveTowards(transform.position, Waypoints[CurrentWaypoint].position, speed * Time.deltaTime); } if (Vector3.Distance(transform.position, Waypoints[CurrentWaypoint].position) < speed * Time.deltaTime) { transform.position = Waypoints[CurrentWaypoint].position; CurrentWaypoint--; if (CurrentWaypoint < 0) { CurrentWaypoint = Waypoints.Count - 1; } LastPause = Time.time + PauseTime; Rotator.turnTowards(Waypoints[CurrentWaypoint].position); } }