In the procedural content examples available on the main website there is an example of a cube take a smooth random walk within a certain area using Perlin noise. I tried to get this example to work on a different project, but kept getting errors so I decided to just redo it.
// BrownianMotion.js
var impulseScalar : float = 1;
var moveRadius : float = 5;
var anchor : GameObject = null;
private var tooFarAway : boolean = false;
private var impulseAwayFromAnchor : boolean = false;
private var impulseVector : Vector3 = Vector3.zero;
function FixedUpdate () {
impulseVector = Vector3(Random.value,Random.value,Random.value);
impulseVector -= Vector3(0.5,0.5,0.5);
impulseVector *= impulseScalar;
tooFarAway = moveRadius < Vector3.Distance(anchor.transform.position , transform.position);
impulseAwayFromAnchor = 0 > Vector3.Dot(impulseVector, anchor.transform.position - transform.position);
if ( impulseAwayFromAnchor tooFarAway )
impulseVector *= -1;
rigidbody.AddForce(impulseVector*Time.deltaTime, ForceMode.Impulse);
}
It tries to keep the attached object within a certain range of an anchoring object (or a position vector, with a tiny tweak). When it exceeds this range, it will only have force applied on it that points towards (within 90 degrees of) the anchor.
The above example code works fairly well on a rigidbody of mass about 0.1 or 0.2.
I have noticed that if you leave it running for a long period of time it can build up energy, bouncing off of the edges of its bounding area, and end up oscillating. If this becomes a problem you can give the rigidbody some drag.