Moving game object at its own when using Physics 2D

Hi folk,
I’m trying to use linecast to detect interference between player and enemy in a 2d platformer game.
when I put the enemy in a specific layer to be used in linecast detection, the enemy starts moving constantly without any script, input from my end. Everything works just fine except that the enemy moving at its own when I assign it to a layer.

here is my code:

void detectEnemy()
{
myDetector = Physics2D.Linecast(startPoint.position, endPoint.position,
LayerMask.GetMask(“Enemy Layer”));
Debug.DrawLine(startPoint.position, endPoint.position);
if (myDetector)
{
Debug.Log("Enemy Detedted as: " + myDetector.collider.name);
}
}

The above code does not manipulate (write to) transforms so it is quite unlikely the above code is involved in what you observe.

This means it is time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.