- Home /
Lock look rotation first person.
How can I lock look rotation on targets smoothly this code works but does not alter the y axis and the camera is tilted when all targets are down. How can I smoothly restor the original position of the camera? thanks in advance!
void Update () {
if(Input.GetKeyDown(KeyCode.Tab) || selectedTarget.GetComponent<EnemyHealth>().enemyDown == true){
TargetEnemy();
}
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(selectedTarget.position - myTransform.position), rotationSpeed * Time.deltaTime);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613081301im_/https://answers.unity.com/themes/thub/images/avi.jpg)