# Movement of objects?

Hello, I have some questions about moving objects:

1: I want to have an object just continue to move until it hits a wall, bounce of and just keep going. I have tried using this script on a rigid body, with turning of gravity and rotation but eventually it will stop(and if I set the function to update, the force is only in one direction). How can I can accomplish what I want, I just want something to bounce around?

``````function Start() {
rigidbody.velocity = Vector3(10,0,10);
}

``````

2: Is there any way to cause an object to move away from another object when the second object comes into a certain distance of the first object?

``````var myVelocity:Vector3 = Vector3(10,0,10); // Normalized direction
var myMagnitude:float; // Magnitude of the movement;
var myForce:float = 0;

function Start()
{
myMagnitude = myVelocity.magnitude;
rigidbody.velocity = myVelocity; // Start off the object
}

function Update(){
// Update the speed with a force every second
if ( rigidbody.velocity.magnitude < myMagnitude  )
myForce += Time.deltaTime;

else if ( rigidbody.velocity.magnitude > myMagnitude  )
myForce -= Time.deltaTime;

rigidbody.AddForce (myForce * Vector3.forward);   // Keeps moving the object forward at a constant speed
}

``````