I am trying to “set the gameObject loose” when i press the Space bar. I cant seem to find any help using Google.
Here is my code so far:
private bool hasStarted = false;
public int Speed = 100;
if(Input.GetKey(KeyCode.Space) && (hasStarted == false))
{
transform.Translate(moveDirection * Speed * Time.deltaTime);
}
It is being run in update, and as i said above, i’d like to have it move constantly after Space has been pressed once, while not being held down
Try this:
private bool hasStarted = false;
if(Input.GetKey(KeyCode.Space) || (hasStarted == true))
{
transform.Translate(moveDirection * Speed * Time.deltaTime);
hasStarted = true;
}