Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Making a flight script dependent on several variables activated by another script.

$
0
0
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.

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>