So, i want a ammo crate type thingy, and i want the player to hold down “E” in 2 seconds and get the ammo. If he lets go, the time or something stops. Is that possible? If so, how?
2 Answers
2You could use Time. For example increment a variable each frame with Time.deltaTime, combined with the Input.GetKey function to detect when the user press E (all of this within the Update function of course).
Input.GetKey - Returns true while the user holds down the key identified by name. Think auto fire.
Input.GetKeyDown -Returns true during the frame the user starts pressing down the key identified by name.
Input.GetKeyUp - Returns true during the frame the user releases the key identified by name.
read these: