Granade throw logic

My case is,

We are developing Kart racing kind of game, the player is fighting with each other and trying to reach final point .

The thing is I am confused over how to implement following logic,

THe player has missile and granade as weapons.

I can do Missile lock ,then missile follows enemy and hit enemy with it. (Vector3.MoveTowards()).

But how to do grenade?

Suppose both enemy and players are moving foreword in Z axis ,

Case 1:

``````Player throws granade at enemy.

It goes and hit enemy.
``````

**I can do this same as missile logic.

Case 2:

``````Player throws granade at enemy.

ENemy change position on X axis (right ,left).

Granade should not follow player to next position.
``````

**Confused over this case, how to let granade not change its position and get blast at surface??

Simply get the position of enemy when the player throws grenade.

That will be the target of this grenade, thus only flying and hitting that position.

For instance, your missile code would be

``````missile.transform.position = Vector3.MoveTowards(missile.transform.position, enemy.transform.position, Time.deltaTime * speed);
``````

Now, in throwGrenade :

``````Vector3 targetPos = enemy.transform.position;
``````

in Update :

``````grenade.transform.position = Vector3.MoveTowards(grenade.transform.position, targetPos, Time.deltaTime * speed);
``````

For those who are looking for similar thing,this script here work for me perfectly (with little modifications) http://forum.unity3d.com/threads/throw-an-object-along-a-parabola.158855/