So I have this code where I move a ball by either clicking or when a function is called. But it only works with the mouse button. When the function vuela() is started it instantiates a ball and SHOULD send it flying but it doesn’t… but if i click the mouse button then it works Whats the problem. Thank you in advance.
CODE:
public GameObject pelota;
void Update()
{
if (Input.GetButtonDown ("Fire2"))
{
GetComponent<Rigidbody> ().AddForce (new Vector3 (500, 500, 0));
}
}
public void vuela()
{
Instantiate (pelota, new Vector3 (5, 0, 0),Quaternion.identity);
GetComponent<Rigidbody> ().AddForce (new Vector3 (500, 500, 0));
}
}