First Person character controller, running script problem

Hey

So basically I created a first person controller and then created a new javascript (NewBehaviourScript) to add a running function.

For now I would like the k key to make the character run but it’s not working. Maybe I am not connecting the script properly to the fp controller?

#pragma strict

var RunSpeed : float = 30.0; 

function Start () {

}

function Update () {

if (Input.GetButton ("k")){
transform.Translate(Vector3.forward * RunSpeed);

}


}

I made a variable called RunSpeed so that when a key is pressed in this case k, vector3.forward is transformed by the amount in the RunSpeed variable.

Or maybe Vector3.Forward is the wrong variable to change? Anyway after I created this I dragged it into the first person controller in the hierarchy

I am quite new to programming so sorry for my ignorance

Unity provides a fp controller but can we modify that controller by adding new things like running or even crouching? If so how do you link the script to the fp controller. I dragged it into the heirarchy and then when I clicked on the fp controller right at the bottom there was a ticked checkbox on the script so the script must be wrong?

(tip) In case you don’t know you can drag the scripts over to the inspector to add to a selected object.

Trouble shoot - Try a Debug.Log to see if your Input is working.

Debug.Log(name + " - Is Working"); // GameObject name and message

Did you setup the Input button ? Because if you did not then you will get an error about that to the console.

After setting up my Input and making sure its on a GO the script works fine.

The cc script that comes with Unity is a little advanced. There are a few alt walker scripts on the Unify Wiki.

Hey black mantis, thanks

How do you setup the input button? I went into Project Settings > Input and I couldn’t find “running” input I created for r so am I doing something wrong?
is a first person controller a game object? So can I do

Debug.Log(name + " - Is Working"); // GameObject name and message

what would I put in ‘name’ to test if the k (running) is working?

Sorry again I am new to Unity and java programming

Other than that does the code look fine, so if I were in the right settings and setup the input would the running work?

Also another question out of curiosity.

Is it better to create a script, drag it into the first person controller then edit the script from there and save it…

or

Create the java script, open it up, do programming, save it and only after drag it into the fpcontroller