- Home /
How do i make a player press a button some time?
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?
Answer by Sevauk · Nov 17, 2013 at 08:07 PM
You 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).
Answer by salex100m · Nov 17, 2013 at 07:25 PM
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: http://docs.unity3d.com/Documentation/ScriptReference/Input.GetKeyUp.html http://docs.unity3d.com/Documentation/ScriptReference/Input.html
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
MoveAround Failed Fire Ball 1 Answer
Script Not Working At All.... :) (SOLVED) 1 Answer
How to disable lighting on text ? 1 Answer
Picking up an object 1 Answer