rotate enemy toward player over time
The examples I have come across all involve rotating in terms of a specific number of degrees over time. I am using the transform.LookAt (target); but the enemy just snaps to that rotation. Which is fine if I am just off to one side of the enemy's forward, but if I am behind him it looks bad. The enemy is unaware of me until I get within a certain distance, then he goes off his waypoint paths and attacks me with navmesh agent . the code below is what I found that looks as though it is the most promising. Thing is...I can't put this in the UpDate function. It is in a coroutine. The Update function is where I randomly select the enemy's next waypoint so the "getHim" variable hasn't been determined yet. public RotationSpeed float I can set at 1 or 1000 at this point and makes no difference
private IEnumerator DelayAfterJump(){
yield return new WaitForSeconds(timeWhileJumping);
anim.SetTrigger("walk");
anim.ResetTrigger("idle");
agent.SetDestination(getHim.transform.position);
enemy.transform.LookAt(getHim);
enemy.transform.Rotate (Vector3.up *(RotationSpeed * Time.deltaTime));
Your answer
Follow this Question
Related Questions
How to rotate around an axis so that another axis always points down? (see images) 0 Answers
Substitute transform.rotation + slerp with transform.rotate and Vector3 0 Answers
transform.LookAt() makes object flip around when too close? (FPS Gun Position Question) 0 Answers
Opening door script in C# 3 Answers
Object rotation naturally change 0 Answers