I am making a game for iphone/Ipad where the main character has to throw grenades against his enemies when I double tap on the screen. As I foresee very simple the situation -which is not- I choose a Javascript included in the Unity documentation:
// Instantiates a projectile whenever the user taps on the screen
var grenade : GameObject; var GrenadeForce : Float;
function Update () {
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began){</p>
clone = Instantiate (grenade, transform.position, transform.rotation);
//add force to the grenade
grenade.rigidbody.AddForce(transform.forward * GrenadeForce);
}
}
}
But when I tap on the screen the character drop the grenade on the floor; he do not throw the grenade away regardless the GrenadeForce that I write down on the script.
What am I doing wrong?
Someone could help me on this?