- Home /
Question by
germanserranoacosta · Jan 06, 2014 at 06:33 PM ·
keyframe
key is repeated 5 times.
I want every time the key is pressed but will add 1 add 5 ¿¿anyone knows why and how to fix this:??
var credit:int=0;
function Update () {
if(Input.GetButtonDown("jugar")){
_root.credit ++;
}
}
result: credit=5; ??????
Comment
Answer by jimmycrazyskills · Jan 06, 2014 at 07:04 PM
Probably wrong because i'm a noob at unity :)
var credit : int = 0;
function Update(){
if(Input.GetButtonDown("Your_Key_Here")){
credit += 1;
}
}
Hope that works ;)
Did that work? / Was that what you meant by your question?
Answer by Bunny83 · Jan 06, 2014 at 07:20 PM
Your script will only add 1 to credit. You probably have added this script 5 times to one or multiple objects in the scene.
Your answer
Follow this Question
Related Questions
USB, MYSQL from Unity 3D free 0 Answers
why wont my demo load (it says i dont have the script) 1 Answer
acces variables from other script 2 Answers