-1

I new to unityscript and am making a platformer game in Unity 2D but my character Movement script won't work. I assume that the function isn't being called but it used to work.

this is the code:

#pragma strict

var JumpSpeed : float = 10;
var walkSpeed : float = 10;
var gravity : float = 50;



function update () {
    var Controller : CharacterController = GetComponent(CharacterController);
    var vertical : Vector2 = transform.TransformDirection(Vector2.up);
    var jump : Vector2 = transform.TransformDirection(Vector2.zero);

    if(Input.GetAxis("Vertical") || Input.GetAxis("Jump")){
        Controller.Move((vertical * (walkSpeed * Input.GetAxis("Vertical"))) * Time.deltaTime);
        Controller.Move((jump * (walkSpeed * Input.GetAxis("Jump"))) * Time.deltaTime);
    }
}

this code has no syntax errors.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • "*it used to work*" - so what did you change? – David Thomas Jan 25 '15 at 21:56
  • There are syntax errors in the code, all of the variable declarations are incorrect - did you intend this to be a Javascript question? – nril Jan 25 '15 at 22:01
  • How exactly is this `var JumpSpeed : float = 10;` legal javascript? or `#pragram strict` for that matter. What language to you really intend for this to be? – jfriend00 Jan 25 '15 at 22:01
  • @jfriend00 it's not javascript, it's [unityscript](http://stackoverflow.com/questions/tagged/unityscript) – undone Jan 25 '15 at 22:15
  • @undone - the OP tagged is as javascript so thus my comment and the title still refers to javascript. I guess you changed the tag. – jfriend00 Jan 25 '15 at 22:22

1 Answers1

2

you need to use U not u to using Unity3D's update method. update -> Update

function Update () {
    var Controller : CharacterController = GetComponent(CharacterController);
    var vertical : Vector2 = transform.TransformDirection(Vector2.up);
    var jump : Vector2 = transform.TransformDirection(Vector2.zero);

    if(Input.GetAxis("Vertical") || Input.GetAxis("Jump")){
        Controller.Move((vertical * (walkSpeed * Input.GetAxis("Vertical"))) * Time.deltaTime);
        Controller.Move((jump * (walkSpeed * Input.GetAxis("Jump"))) * Time.deltaTime);
    }
}
Barış Çırıka
  • 1,570
  • 1
  • 15
  • 24