Raycast to a vector3 point

Ok, I have these objects that select a random vector3 point at the start of the script. What I need is for the object to send a raycast to the point, make sure there is nothing blocking, then move.

I had a small play with some raycasting but couldn’t get it to raycast to the point, any help would be much appreciated.

Ah, yes you’re right… Heres what I came up with, though it turns out its not what I needed.

First I got the point -

targetpos = Vector3(Random.Range(-2000, 2000), transform.position.y, Random.Range(-2000, 2000));

Then I did a raycast to the point -

var hit : RaycastHit;
if (Physics.Raycast (transform.position, targetpos, hit)) {
    Debug.Log(hit.point);
}

That did a raycast to the point but I soon realised it wasn’t what I wanted.