- Home /
Walking script not working need help
Hey im kinda new on unity and i was making this script but it dosnt work :s i can move my character thing with this?
var walkAcceleration : float = 5;
var cameraObject : GameObject;
function Start ()
{
transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(MouseLookScript).currentYRotation, 0);
rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration, 0, Input.GetAxis("Vertical") * walkAcceleration);
}
can some one help me with this??
Answer by noooodley · Aug 12, 2013 at 07:34 AM
In Unity, the Start function is run once at the beginning of the script's creation. You need to use the function Update instead, which is called once per frame. So instead of :
function Start() {
//your code here
}
you should change it to:
function Update() {
//your code here
}
Hope this helps.
I'm glad this helped! If you are able, you should mark this answer as the correct answer :)
Your answer
Follow this Question
Related Questions
Door script not working when door is turned 90 degrees 1 Answer
Script working on some objects but not others 1 Answer
script not working on second character 1 Answer
Can't get bullet to spawn and move 1 Answer
GuiButton Going To Next Level 0 Answers