Apply opposite force on mouse-click + collision


I'm trying to create something where the aim is for the player to hit a ball-object.

It's first person so there will be a bat object visible, when the player clicks I want to test if there is a ball-object near and if so, apply a force to the ball in a negative direction.

How do I go about doing this?

To completely reverse an object's velocity, just do this:

rigidbody.velocity = -rigidbody.velocity;

That will make it reverse mid-air. After that, you could apply variance to the vector, or use rigidbody.AddForce to make the ball move in a slightly different direction (akin to baseball).

The above didn't work in the script?