- Home /
character controller move, strange behaviour
Hi. I have an enemy i want to move to the player. But in some cases the enemy doesnt move, see here:
The guy in the middle is the enemy. If the player is in the green areas the enemy is moving, if the player is in the read areas, he isnt.
Here is the part of the script:
function Update () {
moveDirection = player.transform.position - transform.position;
moveDirection.Normalize();
distanceToPlayer = (player.transform.position - transform.position).magnitude;
if(distanceToPlayer <= 10 || stumbling){
if(stumbling){ finalMoveDirection = -moveDirection * 2; }
else{ finalMoveDirection = moveDirection; }
Control.Move(finalMoveDirection * Time.deltaTime);
}
}
Any ideas ? D:
/edit: Just to make sure you get what i mean: I WANT the enemy to move no matter where the player is, but he isnt atm while the player is in the red areas, and i want that to get fixed.
Your answer
Follow this Question
Related Questions
How to make rigidbody.AddForce and controller.Move work together? 0 Answers
Objects move on play 3 Answers
Vector 3 - move on only one axis 0 Answers
Get which way the player is moving from character controller.move 2 Answers
How to make an object without Rigidbody move at the same speed as an object with Rigidbody? 1 Answer