-2
\$\begingroup\$

I recently posted this How To Make My First Person Controller turn left and right in unity 5

but now I'm having a slight problem when I press the key that turns my camera it only does it for a little and then it stops. I want to be able to hold say the A or D key in and continue turning until I stop holding that key.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Input.GetButton() instead of Input.GetButtonDown()

The former checks to see if the key is currently down and outputs true for every frame during the press. The latter checks to see if the key was up last frame and down this frame (that is: true for exactly one frame until released again).

\$\endgroup\$
5
  • \$\begingroup\$ You might want to briefly introduce the difference between the two functions and why it would fix the issue the OP has. \$\endgroup\$ Commented Feb 3, 2016 at 16:59
  • \$\begingroup\$ yes please explain how to do this a little better please. \$\endgroup\$ Commented Feb 3, 2016 at 17:41
  • \$\begingroup\$ I have updated my answer, @sketcherskt however I am unsure how much use it will be as your question doesn't indicate what scripts you are using and how much knowledge you have of writing code. \$\endgroup\$ Commented Feb 3, 2016 at 17:49
  • \$\begingroup\$ im the using the "first person controller" \$\endgroup\$ Commented Feb 3, 2016 at 18:06
  • \$\begingroup\$ @sketcherskt That involves 3 different scripts, easily. \$\endgroup\$ Commented Feb 3, 2016 at 18:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.