I have a script:
var boxprefab : Rigidbody;
function Update () {
if (Input.GetKey("up"))
{
Instantiate(boxprefab, transform.position, transform.rotation);
}
if (Input.GetKey("space"))
{
Instantiate(boxprefab, (transform.position), transform.rotation);
}
}
but when i press space or up it creates the Rigidbody for a bit and the game starts to lag and not receive any key presses until the Rigidbodys have deleted themselves. How can i make it so that it doesn't lag?