- Home /
Question by
MegaCookie · Aug 02, 2013 at 07:31 PM ·
speedfirst-person-controllerforward
Set default forward speed in first person controller
How to set the default forward speed in the first person controller so when the games runs it has automatically a default forward speed and it ignores further forward speed by the player.
Comment
This works now transform.Translate(Vector3.forward * Time.deltaTime);
but now I can only move sideways when I press the up/ W button too.
Best Answer
Answer by MegaCookie · Aug 02, 2013 at 09:12 PM
Ok I've fixed it my self: In the FPSInputController.js you have a line:
// Get the input vector from kayboard or analog stick
var directionVector = new Vector3(Input.GetAxis("Horizontal") , 0, Input.GetAxis("Vertical"));
Now here you can just edit this line and multiply the Input.GetAxis with the speed you want. And since I didn't needed the Vertical input I deleted the Input.GetAxis("Vertical") and set it to just only the new speed.
Answer by Nexonity · Aug 02, 2013 at 08:33 PM
Maby this?
float speed = 2.0f;
void Update()
{
transform.position += transform.forward * speed * Time.deltaTime;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613111434im_/https://answers.unity.com/themes/thub/images/avi.jpg)