Instantiate gameobject a certain distance away from transform

I'm thinking about the best ways to make a world war II style Anti Aircraft gun(with the puffs of black smokey explosives all around the target).

I was hoping it would be possible to first get the distance of the target with:

var distance = Vector3.Distance(transform.position, target.position);

And next instantiate an explosive gameObject at that distance with slight random rotations and distances applied. I'm not sure how to do this though.

If you can give me any tips for this method, or if you have another method that would be better to implement I would like to know.

Thanks in advance for any help.

Here are some links that should help you out.

If you just want the puffs to appear at random positions around the target, then the position of the gun should be irrelevant. You can use Random.onUnitSphere to get a vector with a random direction.

This will set puffPosition to be at a random point 2 to 4 units away from the target position:

var puffPosition : Vector3 =
    target.position + Random.onUnitSphere * Random.Range(2.0, 4.0);