I’ve tried googling it but none seemed to work for me.
How can I make an object follow and LOOK AT an another object while they both move?
LookAt doesn’t work properly in 2D.
Thanks!
/////
Here is my current code to follow the object.
It doesn’t contain any code to look at the object.
public Vector3 objectPosition;
private Vector3 diff;
public static float speed = 5.0f;
// Use this for initialization
void Start () {
transform.position = new Vector3 (0,25,0);
}
// Update is called once per frame
void Update () {
Vector3 playerPosition = GameObject.FindWithTag("object").transform.position;
transform.position = Vector3.Lerp (transform.position, objectPosition, Time.deltaTime * speed);
}