- Home /
Why does my var speed say it is wrong
Title says it all when i typed the code it says unexpected char: 0xFEFF. (BCE0044) i know i know i sound like a whining noob put i wanted to learn gaming development and now that i have it and my code is not working it's hard for me 2 continue. Here is my code i put down. #pragma strict
function Start () {
}
var speed = 3.0;
var rotateSpeed = 3.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);
}
@script RequireComponent(CharacterController)
Please if u know whats wrong tell me
Answer by Dexter.Unity · Dec 05, 2012 at 10:25 PM
You simple place this script ON the character you want to move. I think it should work.
A few lines where wrong, here you can read how to move an object around:
http://docs.unity3d.com/Documentation/ScriptReference/Transform.Translate.html
var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
{
//Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
//Move forward / backward
transform.Translate(Vector3 (0,0,Input.GetAxis ("Vertical")) * speed * Time.deltaTime);
}
Your script has actually nothing to do with the script in question. He uses the CharacterController component. Your script doesn't perform collision detection.
Dexter.Unity i have one thing to say.....I LOVE YOU $$anonymous$$AN!!!!! (no homo) THAN$$anonymous$$S A BUNCH IT WOR$$anonymous$$S!!!!!! :D
hmmmmm that is weird....when i move it for a while it'll start to bounce and the sphere wont move . What is happening now D:
Are you moving the sphere as a character that's experiencing gravity?
Answer by Bunny83 · Dec 06, 2012 at 12:11 AM
There's nothing (visible) wrong with your script. The character 0xFEFF is a special character at the beginning of a unicode file (it's the byte-order-mark).
Try to change the encoding of your file. Check the save dialog of your texteditor for the encoding format. This is actually the same question.
it ok it works tho i'll save that^ on my notes about this, Bunny83. That is really good to know later on ^.^
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do you code in unity 3.5 and what if any programs would you need 2 Answers
Having some issues with firing a "projectile" 1 Answer
How do I make a respawn system? 1 Answer
I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer