I am creating a game based off of the classic Lunar Lander game and have encountered an issue. I have the following code attached to the player object, and Unity freezes and refuses to respond when I try to play the game. If anyone can figure out what is going wrong, that would be much appreciated. Thanks!
Code:
using UnityEngine;
using System.Collections;
public class VeerusMove : MonoBehaviour {
//moving is false, downSpeed is 0.0, and Rigidbody2d is shortened
bool moving = false;
float downSpeed = 0.0f;
public Rigidbody2D rb;
void Start()
{
//Shortens Rigidbody2d
rb = GetComponent ();
}
void Update ()
{
//adds a constant force
rb.AddForce (transform.up * downSpeed);
//Makes the constant force decrease when moving is false
while (moving = false){
downSpeed–;
}
//Sets moving to true while the spacebar is presed
if (Input.GetKey(KeyCode.Space)){
moving = true;
}
//Sets moving to false when the spacebar is released
if (Input.GetKeyUp(KeyCode.Space)) {
moving = false;
}
//Makes the constant force increase while moving is true
while (moving = true) {
downSpeed++;
}
}
}