Speed Ball script

I have a ball that roll on a plane. How I can make it speed up when it hit a collider?

Add this to the script to any objects which should give an extra kick to the ball when they collide with it. This is useful in situations such as a pinball table, where only certain objects should give the ball a strong kick. (This script assumes the ball is tagged "Ball").

var bounceForce : float = 2;

function OnCollisionEnter(c : Collision) {

    if (c.collider.CompareTag("Ball")) {

        // give the ball extra force in the direction that its currently moving:

        var rollDirection = rigidbody.velocity.normalized;
        rigidbody.AddForce( rollDirection * bounceForce );



Alternatively, you could probably implement this using custom Physic Materials, and set the bounce value to a high number, however I would go with the scripting method, because generally you would need a handler like this to perform other actions too such as playing a sound effect and adding score, so my feeling is that it would make sense to have these things grouped together as a script, but that's up to you!

But how I can say to it that I want one just one collider

It said to me that i'm not allowed to call get_rigidbody in a variable.