SHOOT CORRECTLY DAMN GRENADE THING

Well... Heres the problem. Since my game is a rail-shooter, I want to make it such that you can throw a grenade forward, from where you click the screen.

So lets say you click the top left area of the screen, a grenade will spawn and bounce forward before exploding.

I managed to get the spawning and the explosion-ing part done quite well. But I have this strangest problem.

NO MATTER WAY, THE GRENADE WILL ALWAYS BOUNCE TOWARDS THE SAME POINT.

Like, for example, lets say the point this time is somewhere in front of me. No matter WHERE I CLICK ON THE SCREEN, the grenade's direction will ALWAYS be facing that point, so all grenades will bounce towards the same place. And I can't possibly have that.

Can someone please tell me whats wrong? Heres the code I used for the spawning:

            var theVector =  Input.mousePosition;
        theVector.z = 1;
        var thrownItem = Instantiate(fullWeaponsList[currentWeaponNum].thrownObject, Camera.main.ScreenToWorldPoint(theVector),Camera.main.transform.rotation);

And heres the code I used for movement:

function Awake(){
rigidbody.AddRelativeForce(Vector3(0,0,1000));

}

You're using the same rotation no matter what the position you click is

try something like this for the spawn rotation (untested, but you get the idea):

Quaternion.LookRotation(Camera.main.ScreenPointToRay(theVector).direction)

The problem is in your Instantiate method. Your second parameter is the spawn location, which in your case (using ScreenToWorldPoint) will be whereever you click.

Your third parameter, is the rotation of your instantiated object. You use Camera.main.transform.rotation which returns the cameras rotation. This rotation will always be the same. That's why no matter where you spawn your grenade, it will always head in the same direction (the direction of the camera).

Instead, you probably want to instantiate the grenade at the same position always, but instead have the direction change.

Try this:

var theVector =  Input.mousePosition;
    theVector.z = 1000;
    var thrown = Instantiate(prefab, Camera.main.transform.position,Quaternion.LookRotation(Camera.main.ScreenToWorldPoint(theVector)));

In the above code, the grenade will always be spawned at the cameras location, but the rotation will be different: It will be rotated towards where you clicked on the screen, instead of where the camera is looking. The Z value is set to 1000 in this case. In your specific case you might want to increase or decrease the Z value, depending on the scale of your scene.