How to instantly move a newly instantiated prefab?

I am trying to write a class that randomly picks between four prefabs from a Resource Folder, instantiates the randomly picked prefab, and places said prefab in a random location. I have the first two parts working, but I can’t seem to get the prefab placed where I want it. Instead, it always instantiates where I had the object when I made it into a prefab. What am I doing wrong?

Here’s the code I’m using to try to place the prefab. xCoord and yCoord are the x and y coordinates that I want the prefab to be at, and obstacle refers to the prefab itself.

xDiff = xCoord - obstacle.transform.position.x;
yDiff = yCoord - obstacle.transform.position.y;
obstacle.transform.Translate(xDiff, yDiff, 0f);

Why aren’t you using the instantiate with positioning information?

static Object Instantiate(Object original, Vector3 position, Quaternion rotation);

and just input the wanted position.

obstacle.transform.position = new Vector3(xCoord, yCoord, 0);