it keep saying this Assets/Standard Assets/NewBehaviourScript.js(7,43): UCE0001: ';' expected. Insert a semicolon at the end. but i did what it said and it wont work here my script
var speed = 7.0;
var rotateSpeed = 4.0;
function Update () {
{
controller : CharacterController } GetComponent(CharacterController);
//Rotate around y - axis
transform.Rotate(0, Imput.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3).forward;
var curSpeed = speed * Imput.Getaxis("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script. RequireComponent(CharacterController)
Dude, this is your script laid out neatly:
var speed = 7.0; var rotateSpeed = 4.0;
function Update ()
{
{ controller : CharacterController }
GetComponent(CharacterController);
//Rotate around y - axis
transform.Rotate(0, Imput.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3).forward;
var curSpeed = speed * Imput.Getaxis("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script. RequireComponent(CharacterController)
And this is your script (hopefully) without compilation errors:
@script RequireComponent(CharacterController)
var speed = 7.0;
var rotateSpeed = 4.0;
function Update()
{
var controller : CharacterController = GetComponent(CharacterController);
//Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3).forward;
var curSpeed = speed * Input.Getaxis("Vertical");
controller.SimpleMove(forward * curSpeed);
}
First - try and lay out your scripts so they are readable. Way easier to spot mistakes and go over the codes that way. I hope you just copy-pasted it wrong, because if you continue this way, when your scripts get longer and more complex - they will become more and more of a mess...
Second - I'm all about messing around with the code, trial and error and stuff, but when you're starting out - try and understand the little things as much as possible. Do some tutorials, see some code other people wrote.
Third - try and play spot the difference between what you posted, and the code I did. I don't know exactly which line had the problem, but if you had corrected it - you would have another one, and another one. I spotted at least 3 syntax errors :/
Don't take it hard - I'm not criticizing, just trying to help you out here...
Would this work?
var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script RequireComponent(CharacterController)
You made a couple of mistakes.
o ok thanks for you r help
ya but it says this i tried to fix it but i dont know whats wrong it says
Assets/Standard Assets/NewBehaviourScript.js(14,47): BCE0023: No appropriate version of 'UnityEngine.Transform.TransformDirection' for the argument list '(System.Type)' was found.
heres my scritpt
script RequireComponent(CharacterController)
var speed = 7.0;
var rotateSpeed = 4.0;
function Update()
{
var controller : CharacterController = GetComponent(CharacterController);
//Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3).forward;
var curSpeed = speed * Input.Getaxis("Vertical");
controller.SimpleMove(forward * curSpeed);
}