I don’t know what the issue is. Any help is appreciated.
Hi Marcus,
The only issue you have is that you have KeyCode.UpArrow
within quotation marks. You only need to do that if you are specifying the name, as a string, for the key. If you are providing the actual keycode, as you are, you don’t need them.
So, it’s a nice easy win, just update to this;
void Update()
{
if(Input.GetKeyDown(KeyCode.UpArrow))
{
print("Up arrow pressed");
}
if(Input.GetKeyDown(KeyCode.DownArrow))
{
print("Down arrow pressed");
}
}
Note, it is usually better to copy/paste your code into the topics rather than using screenshots as it means that those who help can copy/paste chunks of your code back for you without having to type it all out.
To format the code nicely you just need to enter some formatting characters before and after it and the forum will do the rest.
Screenshots for details from the actual Unity editor can be beneficial though, error message or details from the Hierarchy/Inspector etc.
Also, welcome to the community!
See also;
- Forum User Guides : How to apply code formatting within your post
Thanks a lot! This was a life saver.
No problem at all, you’re very welcome
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.