ball loses momentum

hi guys i’m creating a “block breaker” game
and i have this one issues that the ball is losing momentum when its hitting the wall
and blocks
although the paddle giving you a starting momentum and and also when it hits it again

but still the ball is losing momentum to almost a complete stop

Not sure how you are moving the ball, but you could probably save the vector that the ball is moving on right before the collision, then apply it to the new direction of the ball, like follows(assuming you are using rigidbodies with addForce):

/save the magnitude of the ball's vector
    lastMagnituide = ballVector.magnituide();
    
    //Change direction of ball
    
    //sets magnituide to 1
    ballVector = ballVector.Normalize();
    
    //sets the new vector to the old vector's magnitude
    ballVector = ballVector * lastMagnituide;

If you are using AddForce to move the ball, the amount of force is the magnitude of the vector, and this saves it before the collision and applies it after, to keep the same velocity.

thanks for your answers
here i uploaded the game i did so you can see for yourself
and also i uploaded my paddle script so you can see(btw my paddle isnt a rigidbody)
paddle script

https://dl.dropboxusercontent.com/u/250309938/Game.html

I think you should have:

  1. A separate script attached to your ball. That is, if you don’t already have one.

  2. Add a tag in the editor for the ball when it becomes active after you press space… Like “Active Ball”, for example.

  3. After you initially AddForce with the spacebar, on line 81 of the code that you have attached above, add this line of code: attachedBall.tag = "Active Ball";

  4. Within the script that is now attached to the ball, do something like this:

    float targetSqrMag = 500.0f; // This is just a guess, find your happy speed with this number

    void Update ()

    {
    
    if( gameObject.tag == "Active Ball" )
    
    {
    
    Vector3 dir = rigidbody.velocity;
    
    float curSqrMag = gameObject.rigidbody.velocity.sqrMagnitude;
    
    if( curSqrMag < targetSqrMag )
    
    {
    
    gameObject.rigidbody.AddForce( dir * 450f )
    
    }
    
    if( curSqrMag > targetSqrMag )
    
    {
    
    gameObject.rigidbody.AddForce( -dir * 450f )
    
    }
    
    }
    
    }
    

I didn’t try this code out, but I think it should do the trick. Let me know if you’re still having troubles.

If you apply a force to the ball at the beginning (or at pressing space bar…) and then make all items which it will contact frictionless and bouncy, then it will never lose velocity. To do this, simply create a physics material with no friction and with a bounciness of 1 and apply it to all items (or prefabs) which the ball will contact. I tested this by doing it myself and it worked as expected.