Hi,
I want to make the object rotate when the player is not looking at it, i already have the script but it’s not working
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LookingAtPlayer: MonoBehaviour
{
public Transform player;
void OnBecamevisible()
{
}
void OnBecameinvisible()
{
Vector3 playerPosition = new Vector3 (player.transform.position.x, transform.position.y, player.transform.position.z);
transform.LookAt (playerPosition);
}
}
reference