how do i make an enemy look at the player only on the x axis and not on the y one,how do i make an enemy look at a player only on the x axis
public mouselook mouselook; public float speed = 20.0f; public float minDist = 1f; public Transform target; public Transform enemylocation; // Use this for initialization void Start() { // if no target specified, assume the player if (target == null) { if (GameObject.FindWithTag("Player") != null) { target = GameObject.FindWithTag("Player").GetComponent(); } } }
// Update is called once per frame
void Update()
{
if (target == null)
return;
// face the target
enemylocation.LookAt(target);
public void SetTarget(Transform newTarget)
{
target = newTarget;
}
i looked online for about an hour and i tried implenting a vector 3 but was unable. can anyone please help? i want the enemy to look at the player(target) only on the x axis and z axis and not on the y axis due to it making it float. is there maybe also a way to make it look at the player - 10x or something like that? also sorry if this question is dumb or has already been answered before since i wasnt able to find a solution./ thanks in advance! ,public mouselook mouselook; public float speed = 20.0f; public float minDist = 1f; public Transform target; public Transform enemylocation; // Use this for initialization void Start() { // if no target specified, assume the player if (target == null) { if (GameObject.FindWithTag("Player") != null) { target = GameObject.FindWithTag("Player").GetComponent(); } } }
// Update is called once per frame
void Update()
{
if (target == null)
return;
// face the target
enemylocation.LookAt(target);
public void SetTarget(Transform newTarget)
{
target = newTarget;
}
i looked online for about an hour and i tried implenting a vector 3 but was unable. can anyone please help? i want the enemy to look at the player(target) only on the x axis and z axis and not on the y axis due to it making it float. is there maybe also a way to make it look at the player - 10x or something like that?/ thanks in advance!