I have a model of a man, that looks in players direction, when close. But when the player jumps, he rotates in a weird upwards rotation, where he almost "lies down". How to prevent him from rotating like that?
This is a piece of my script.
rotate = Quaternion.LookRotation(player.position - transform.position); // transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * slower);
It sounds like you want the model to track the player while only rotating about the 'up' axis. To achieve this, replace this:
rotate = Quaternion.LookRotation(player.position - transform.position);
With this (untested):
Vector3 difference = player.position - transform.position; difference.y = 0; // Syntax here may be language-dependent rotate = Quaternion.LookRotation(difference);