Please help, I have updated my code to include the code in the Update portion however the console within unity is not updating as it does in the video.
I believe that my code is correct, it looks the same as the video. I have saved my work in monodevelop, I even closed and restarted with no luck. I also believe that I have added this script to an object.
I have inserted a photo as a reference, please advise.
The script that shows up in the Inspector tab is the same that is in Monodevelop. The Start code is showing up in the console but the code in the Update portion is not.
This seems like odd behaviour… let’s see what we can work out…
At a first glance of your image the code appears to be good. So, what I would do is add a print statement within the Update() method but outside of the logic that determines if a key has been pressed. What this would tell us is whether that Update() method is being called at all.
You can achieve this with the following code;
void Update() {
print("My Update() method has been called");
if (Input.GetKeyDown(KeyCode.UpArrow) {
print("Up arrow pressed");
}
if (Input.GetKeyDown(KeyCode.DownArrow) {
print("Down arrow pressed");
}
}
The expected behaviour of this change would be that you console would start to fill with lots of My Update() method has been called entries.
Well… I know that it is a silly question, but are you pressing up arrow and down arrow while the game runs? Those methods are supposed to run only when you press those, if you are doing it and still nothing appears, try changing the uparrow and downarrow to something like KeyCode.A and press “A” in the keyboard while the game runs, it could be an Input error. Your code Don’t seems to be wrong to me.
Wow… that was not a silly question at all, all I needed to do was press the up and down arrows. Seems so simple and such a dumb thing to miss in retrospect. My console also started to fill with lots to My Update() so it is definitely the fact that I wasn’t pressing the keys. Thank you both so so much, so happy I can move on I will mark as solved.
It is pretty frequent the problem being just under our nose, it happens all the time with me, a good practice to discover the problem is to print inside each method that involves the problem to see what is causing it just as @Rob was pointing;