unity how to make a gameobject slowly look at a position
Quaternion lookAtSlowly(Transform t , Vector3 target , float speed){
//(t) is the gameobject transform
//(target) is the location that (t) is going to look at
//speed is the quickness of the rotation
Vector3 relativePos = target - t.position;
Quaternion toRotation = Quaternion.LookRotation(relativePos);
return Quaternion.Lerp(t.rotation, toRotation, speed * Time.deltaTime);
}
void update()
{
transform.rotation = lookAtSlowly(transform , new Vector3(0,0,0) , 1);
}