# 2 cubes objects bounce off eachother

Hello, I have made a 3D versjon of pong.

I have a a paddle that player1 controls with this script.
It works fine all directions as it should.

It is a cube object with rigidBody. It has a pysical material on it and on all walls (plane with mesh colider) so the ball can bounce of it.

PysMat: Friction = 0 and Bounciness = 1.

The problem I am trying to solve is when my cube(paddle) hits any wall it starts to “shake and bounce” making it uncontrollable (looks like it gains force in some direction, if I let go off the controls it starts to move on its own). I have at least locked it from spinning of x,y axis by checking all 3 freeze rotation boxes.

I have the same problem without the pysical materials, it just shakes alittle differently. Is there a way I can make 'em not hit each other or constrain the movements of my player controlled cube?

my script for controlling the paddle (cube)

var keyboardSpeed = 20.0;

function FixedUpdate () {

var keyboardX = Input.GetAxis("Horizontal") * keyboardSpeed * Time.deltaTime;
var keyboardY = Input.GetAxis("Vertical") * keyboardSpeed * Time.deltaTime;

var newPos = rigidbody.position + Vector3(keyboardX, keyboardY, 0.0);

rigidbody.MovePosition(newPos);

}

@script RequireComponent(Rigidbody)

solution 1: you should mark rigidbody as kinematic if you want control it directly

solution 2: use ‘add force’ instead of ‘move position’ if you want to control it and let physics work

## edit: fast example of what i mean

http://zammyart.com/UA/RigidbodyTester/WebPlayer.html

arrows or WASD - give ball a force

void Update()
{
rigidbody.AddForce(50f * new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")));
}

## sources

http://zammyart.com/UA/RigidbodyTester/rigidbodytest.unitypackage

I needed to have my paddle rigidBody Interpolate settings set at none and drag at something high like 100 to make the problem less noticeable.