Can someone help, I just want to know when the E key is pressed for picking up objects. I am using mouse down as a placeholder, but that will be used for weapons, I found tutorials for Shift, LControl, and Enter, but no letters/numbers.
Try this in Update:
if (Input.GetKeyDown(KeyCode.A))
{
//weapon stuff here
}
I would recommend using KeyCode.E though.
Definitely
Three years + later?
Yep, I came across this when I was looking for code to check for specific key input, as I am new to programming (I only just got unity today), and the method I found in a video just resulted in an error message.
Don’t necro old threads please.
There is a learn section. It’s a bit hidden but here’s a direct link:
Sorry, but thanks for the link anyway. I will not post on this thread again.
I am having problems it keeps saying Error CS1513
but i have all the brakets in the right places see
public class PlayerMovment : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A));
{
}
else (Input.GetKeyDown(KeyCode.D));
{
}
else if (Input.GetKeyDown(KeyCode.W));
{
}
}
}
PLEASE do not reply to four year old random threads with unrelated questions. It is against forum rules.
Instead, start your own fresh post… it is FREE. When you do, keep these things in mind:
How to report your problem productively in the Unity3D forums:
How to understand compiler and other errors and even fix them yourself:
If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: https://discussions.unity.com/t/481379