public Transform target public int moveSpeed public int rotateSpeed private Transform mytransform; void awake (){ mytransform=this.transform; } void Start() { GameObject go=GameObject.FindGameObjectWithTag("Player"); target=go; } void Update(){ debug.DrawLine(target.transform.position,this.transform.position,Color.yellow); //lock at target Player mytransform.rotation=Quaternion.slerp( myTransform.rotation, Quaternion.LookatRotation(target.position-mytransform.position), rotateSpeed*Time.deltatime ); //Move towards target mytransform.position += mytransform.forward*moveSpeed*time.deltatime; }
Unity之一天一个技术点(十八)---让敌人缓慢转向,并且跟踪玩家
原文地址:http://blog.csdn.net/myk7694503/article/details/43670111