3 dimension ball bounce. Tridimensional arkanoid

Hello all,

I’m new on Unity3D, and im starting programming my scripts.

By now im trying to program a simple tridimensional arkanoid, but I have some problems with the ball bounce, when touches some wall sometimes works ok, but after some bounces it crosses the wall, no bounce produced, and after hours I didn’t found the solution.

Imagine one ball inside a box, bouncing In the walls forever, thats what I need by now.

There is my code:

var velocity : Vector3; 

function Start()
	var speed=1.1;
	var Initial_Impulse:Vector3= transform.position - GameObject.FindWithTag("Player").transform.position; // calculate delta vector
	Initial_Impulse.Normalize(Initial_Impulse); // normalize
	rigidbody.AddForce(Initial_Impulse * speed, ForceMode.Impulse); // Add impulse force in some direction.

function Update() 
	transform.Translate(velocity * Time.deltaTime, Space.World);

function OnTriggerEnter(other : Collider) 
    // Detectamos la colision con cada objeto y con el reflect le damos la vuelta para que rebote en el sentido contrario
    velocity = Vector3.Reflect(velocity, other.transform.right); 
    //transform.position = Vector3.Reflect (transform.position * Time.deltaTime, Vector3.right);

Some idea? :frowning:

Thanks !

The issue of a Rigidbody going through a collider is frequently asked and answered on Unity Answers. There is not a one-size-fits-all solution, nor is there a perfect solution given the discrete nature of Unity’s physics engine. The one change that seems to help the most (and fixes the problem in many situations) is to reduce the fixed timestep. Go to:

 Edit > Project Settings > Time

Reduce the Fixed Timestep. start by changing it from the default of 0.02 to 0.01. This change will capture more collisions, but your app will spend more if its time on Physics calculations. If this does not solve your problem, see out the many answers and suggestions and give them a try. If nothing works, post back with the results of your trials, and someone may have additional ideas for you.