unity follow object when close code example
Example: how to make a gameobject follow another object's path
void Update()
{
transform. position = Vector3. Lerp(transform. position, target. position, speedPosition * Time. deltaTime);
transform. rotation = Quaternion. Slerp(transform. rotation, target. rotation, speedRotation * Time. deltaTime);
}