How to transform object backwards (in opposite direction it was travelling), not on x,y,z axis

Hello - in my game objects move towards the first and third person controller. When the mouse moves onto the object they are transformed away from the controller.

The script works - but I can only work out how to transform the object forwards, up or right, on the x,y,z axis.
Is there a way to move the object backwards, as in the opposite direction it was travelling towards the controller?

This is the script (JavaScript):

var firstPerson : GameObject;
var thirdPerson : GameObject;
 
 
 
function OnMouseOver () {
 
 
    if (firstPerson.GetComponent(CharacterController).active) {
 
        rigidbody.velocity = transform.up * 10;
 
        yield WaitForSeconds (5);
 
        rigidbody.velocity = transform.up * 0;
    }
 
else if (!firstPerson.GetComponent(CharacterController).active) {
 
    rigidbody.velocity = transform.up * 0;
 }
 
 	if (thirdPerson.GetComponent(CharacterController).active) {
 	
 	rigidbody.velocity = transform.up * 0;

}
}

Thanks, Laurien

you can find the direction or vector between the object and you character by subtracting there positions. Once you have that you can use it to move you’re object along that vector in the opposite direction.
Something like this should work:

var firstPerson : GameObject;
var thirdPerson : GameObject;
var Direction : Vector3;

function OnMouseOver () {
	if (firstPerson.GetComponent(CharacterController).active) {
		Direction = (firstPerson.transform.position - rigidbody.position).normalized;
		rigidbody.velocity = -Direction * 10;
		yield WaitForSeconds (5);
		rigidbody.velocity = Vector3.zero;
	}
	else if (!firstPerson.GetComponent(CharacterController).active) {
		rigidbody.velocity = Vector3.zero;
	}
	if (thirdPerson.GetComponent(CharacterController).active) {
		rigidbody.velocity = Vector3.zero;
	}
}

Let me know if you have any problems!

Scribe