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.
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);
}
}