- Home /
Update function - Auto update
I'm currently doing something as making the camera move while holding down the "W" button, yet the Update() function doesn't seem to be automatically updating and reacting to my multiplication of deltaTime.
if(Input.GetButton("Forward")) { transform.position += transform.forward * moveSpeed * Time.deltaTime; }
I press the "W" button and it moves forward. I hold the "W" button and it moves once and only once. Am I missing something?
It looks ok, so probably just something being overlooked like is moveSpeed non-zero? $$anonymous$$ake sure Update is being called by putting a Debug.Log("Update") in Update, but not in an if stmt. If that works, then try it inside your if stmt. Print the value you are trying to add (transform.forward moveSpeed Time.deltaTime), etc.
Hmm each value is printing automatically per update when placed outside of the if statement, however it only prints once per key press when placed inside. $$anonymous$$inda weird.
Printing the multiplied values results in values along the lines of (0.0, 0.0, 0.2).
Answer by darkeligos · Jun 14, 2011 at 05:48 AM
I've found the problem. I was working with a tutorial and did not distinguish between GetButtonDown and GetButton. Using GetButtonDown was not letting the scene update. Thanks for the help hellcats.
Also, you might want to try Get$$anonymous$$eyDown() which lets you move, switch or rotate things on ANY button.
example :
if(Input.Get$$anonymous$$eyDown("r")) { //insert rotation stuff here }
Just keep in $$anonymous$$d to use the lowercase letter since this class is case-sensitive afaik
Your answer
Follow this Question
Related Questions
Force refresh of frame 2 Answers
Auto update PSD files in Unity? 0 Answers
How would one disable the auto update of a Unity Web Player? 5 Answers
FixedUpdate limits: consistant 0.01 s on mobile devices? 1 Answer
Web Player Auto Update Failed 8 Answers