C# Throw GameObject Upon Mouse Click

I’m trying to create a script that throws a gameobject on mouse click. But I’m not sure what code I’m looking for to achieve this. transform.Translate(Vector3.forward * Time.deltaTime); makes the Gameobject move forward continuously without stopping. I want to make it so that the gameobject moves forward very fast and have the gameobject slowly die down till it hits the ground as if you were actually throwing something. Is there other code that modifies a Gameobject’s transforms?

Is there a reason why you’re not using physics to throw it? Adding a rigidbody you could use AddForce on it. Else you could have a float variable as speed by which you multiply Vector3.forward (it will be 0 at start and you set it to 1 or greater upon mouseclick), then use Mathf.Lerp to decrease it down to 0:

Like this for example:

public float throwSpeed = 10;
float speed = 0;

void Update () {
	speed = Mathf.Lerp(speed, 0, Time.deltaTime);
	transform.Translate(Vector3.forward * speed);
	if (Input.GetMouseButtonDown(0))
		speed = throwSpeed;