Question by
Wesley21spelde · Jan 25, 2021 at 08:34 PM ·
wronglookattargetlook at
look at target not working like i wanted
hey guys i have a question dont know if this is correct script does not bug but its stil firing at my enemy`s feet becouse thats the center of the character but i wanted to let it lookAt target + 1unit above the chacacters 0,0,0, position and it freaks out if thare is no target :(
so i changed this
transform.LookAt(target.transform);
into this
transform.LookAt(target.transform,new Vector3 (0, 1, 0));
buyt its stil looking at his feet here is that part of the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LookAtTarget : MonoBehaviour
{
public GameObject target;
void Update()
{
{
target = GameObject.FindGameObjectWithTag("Enemy");
transform.LookAt(target.transform,new Vector3 (0, 1, 0));
}
if (target == null)
{
// do nothing.. dont panic
}
}
}
Comment