For a magic based game I am making, I need there to be a flight script which lets the player fly by pressing the space bar, but only after pressing the keys O P I. I tried doing it several ways. At this point my code looks like this:
function FixedUpdate ()
{
Debug.Log ("Update Called");
if (MainScript.flying == true)
{
if (Input.GetKey(KeyCode.Space))
{
Debug.Log ("Flight Attempted");
var input = new Vector3 (Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
GetComponent.().AddForce(input);
Debug.Log ("Flight Successful");
}
}
}
This does nothing, although all Debug.Logs are being triggered. I do not know if there is any way for this code to work, so it may be necessary to start from scratch. I really don't care anymore so long as it works. Keep in mind that I am relatively new to programming, so try to be specific in your answers as there are a lot of features that I have no clue how to use.
↧