I have an object that can be moved by the user, I would like to restrict its movement to be within a radius of the starting pos
checking its distance to the startpos is easy with
var moveLimit:number = 100
var dist:Vector3D = playerBody.position.subtract(startPos);
if (dist.length > moveLimit) {
//do something to prevent movement
}
I assume I next need to calculate a new position vector thats 100 units along from startpos towards the playerbody position. Anyone know how to do that?