How do i get this guy to hold his position?

the ai character is supposed to rotate on the y axis and look at the player’s character. The problem i’m having is that i have the ai characters positioned in a particular way.

Position is 6, 0, 15
Rotation is 0, -70, 0 (this rotation is looking forward at the screen aka the player’s character)
And the scale is all 1.

when i hit play however,
my ai character changes to rotation to -158.199 (which is looking the left same direction as the player’s character is looking)

How do i fix this so that he holds his rotation while also still following the player’s character?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LookAt_Player : MonoBehaviour {

GameObject target;

// Use this for initialization
void Start () {

	target = GameObject.Find ("FBX_Box_Model");
}

// Update is called once per frame
void Update () {

	Vector3 targetPosition = new Vector3(target.transform.position.x,
		transform.position.y, 
		target.transform.position.z);
	

	transform.LookAt (targetPosition);
	
}

}

public GameObject target;

    private void Update()
    {
        Vector3 targetDirection = target.transform.position - transform.position;
        targetDirection.y = 0;

        transform.rotation = Quaternion.LookRotation(targetDirection);
    }

Your code looks okay, and I can’t find any obvious problems. Are you certain that no other GameObjects besides the player are named “FBX_Box_Model”?

I am also facing the same issue, and i wrote about it in my previous thread. But yeah, i couldn’t find any solution for it so i am writing it here. So this thread might get on top again and we might find the right answer.
By the way i am currently working on a project for Canada immigration Pakistan, so if anyone needs any information about it let me know. Thanks!

Hello,
Any solution on this? It would be of great help.

NPC.transform.forward = (target.transform.position - NPC.transform.position).normalized;
Simply replace NPC and target with the appropriate GameObjects. If you are setting the NPC’s body rotation instead of a separate head axis, simply use this:

NPC.transform.forward = ((target.transform.position  - Vector3.up * target.transform.position.y) - NPC.transform.position).normalized;

This subtracts the target’s Y position from the aiming location, meaning that they will only rotate on the Y-axis instead of on the X.
I hope this helps, and please upvote!