private void UpdateMove() { float x = Input.GetAxisRaw("Horizontal"); // 플레이어 캐릭터의 물리적 이동 movement2D.MoveTo(x); }
private void Awake() { movement2D = GetComponent <Movement2D>(); float x = Random.Range(-1.0f, 1.0f); float y = Random.Range(-1.0f, 1.0f); movement2D.MoveTo(new Vector3(x, y, 0)); }
private void Update() { if (target != null) { Vector3 direction = (target.position - transform.position).normalized; movement2D.MoveTo(direction); } else { Destroy(gameObject); } }
private void Update() { //If there's a target if (target != null) { //Move the projectile object to the target's location Vector3 direction = (target.position - transform.position).normalized; movement2D.MoveTo(direction); } else { //Get rid of the projectile object Destroy(gameObject); } }
private void NextMoveTo() { if (currentIndex < wayPointCount - 1) { transform.position = wayPoints[currentIndex].position; // 이동 방향 설정 다음 목표지점 currentIndex++; Vector3 direction = (wayPoints[currentIndex].position - transform.position).normalized; movement2D.MoveTo(direction); } // 현재 위치가 목표지점이면 else { Destroy(gameObject); } }
private void NextMoveTo() { if (currentIndex < wayPointCount - 1) { transform.position = wayPoints[currentIndex].position; currentIndex++; Vector3 direction = (wayPoints[currentIndex].position - transform.position).normalized; movement2D.MoveTo(direction); } else { gold = 0; OnDie(EnemyDestroyType.Arrive); } }
private void NextMoveTo() { if (currentIndex < wayPointCount - 1) { transform.position = wayPoints[currentIndex].position; currentIndex++; Vector3 direction = wayPoints[currentIndex].position - transform.position; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle + angleOffset)); movement2D.MoveTo(direction.normalized); } else { state = State.END; } }
private void NextMoveTo() { //If there's still a way point left for the enemy to move to if (currentIndex < wayPointCount - 1) { //Set the enemy right on top of the way point transform.position = wayPoints[currentIndex].position; //To next way point currentIndex++; Vector3 direction = (wayPoints[currentIndex].position - transform.position).normalized; movement2D.MoveTo(direction); } //If there's no way point left for the enemy else { //To ensure that the enemy doesn't give credit to the player when the enemy dies in base credit = 0; //Remove the enemy object OnDeath(EnemyDestroyType.Arrive); } }