유니티 C# 플레이어를 추적하는 적 코드 간단 구현 Unity


유니티 C# 플레이어를 추적하는 적 코드 간단 구현 Unity

코드 작성 using UnityEngine; public class Enemy : MonoBehaviour { public float speed = 5f; private Transform player; void Start() { // 태그로 플레이어 찾기 player = GameObject.FindGameObjectWithTag("Player").transform; } void Update() { Vector3 direction = player.position - transform.position; direction.Normalize(); transform.position += direction * speed * Time.deltaTime; } }


원문링크 : 유니티 C# 플레이어를 추적하는 적 코드 간단 구현 Unity