How do I stop a moving object when the Camera sees it

This is just a simple thing I want to do. I have my cylinder gameobject moving up and down and I want to make it so when the camera sees it, it stops moving. So, it’s not moving at all. If anything, it will move for a split second before stopping. If you could steer me in the right direction, I’d appreciate it. thank you
public class cylinderMove : MonoBehaviour, MoveObject {

public float delta = 1.5f;  
public float speed = 2.0f;
private Vector3 startPos;

private bool seen = false;

public void OnBecameVisible()
{
    seen = true;
}

public void OnBecameInVisible()
{
    seen = false;
}
void Start()
{
    startPos = transform.position;
}

void Update()
{
    if (!seen)
        move();
}
public void move()
{
    Vector3 v = startPos;
    v.y += delta * Mathf.Sin(Time.time * speed);
    transform.position = v;
}

}

If the game object reaches the coordinates of camera then set the body type of the game object to kinematic.

In your update

a = GameObject.Find(yourGameObject).transform.position.x;

if(a< positionofyourcamera ){

yourgameobject.isKinematic = true;

}

That will somehow give you idea. :slight_smile:

ps: I am new :slight_smile: