- Home /
Unexpected char : 0x0
Hello everyone! I am struggling with a piece of my sprinting script. I have added in a block of code that says when you press left shift it plays the running animation and when you let go, it stops it!
When I saved it I got an error saying: BCE0044: unexpected char: 0x0.
Here is the code:
var walkSpeed : float = 7; // Regular Speed
var sprintSpeed : float = 13; // Run Speed
private var charMotor : CharacterMotor;
private var charController : CharacterController;
function Start () {
charMotor = GetComponent(CharacterMotor);
charController = GetComponent(CharacterController);
}
function Update () {
// Making the actual speed var
var speed = walkSpeed;
// Checking for oppertunity to sprint
if(charController.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift")){
speed = sprintSpeed;
}
// Changing the speed to sprint
charMotor.movement.maxForwardSpeed = speed; // Setting the speed
if(Input.GetKeyDown(KeyCode.LeftShift)){
animation.Play("m4_run");
}
if(Input.GetKeyUp(KeyCode.LeftShift)){
animation.Stop("m4_run");
} // This is where the error keeps on pointing to
}
If anyone could help I would be very grateful :)
I just copied and pasted the code from above, and it worked fine, so copying and pasting into UA fixed the problem. You should be able to just copy and past the script back in from your question.
Answer by Bunny83 · Jul 28, 2013 at 04:46 PM
You somehow managed to copy a null-byte-character into your source code. Try open the file in another editor and resave the file. That might help. Other than that i would use a hexeditor and search for the null byte. You usually can't see the null character, so it's hard to delete it inside MonoDevelop.
btw: Shouldn't Unity give you at least a line number and a column where the error occured?
@Bunny83 30,10 is the line number and column! Also thanks for that :D
Boy that was an experience, after deleting about 14 'null' (?) lines, I then had to press the delete (not backspace) button on the last line to clear the rest of my code letter by letter. Fortunately I was only 14 lines in. That was really strange. Thank you nonetheless
Answer by Mikey_Bad052 · Nov 06, 2016 at 09:29 AM
This happens to me to this is a pickup item code here it is: var target : Transform;
function Update () { }
function OnMouseDown () { this.trasform.position = target.position; this.transform.parent = GameObject.Find("FPSController").transform; this.transform.parent = GameObject.Find("FirstPersonCharacter").trnsform; }
function OnMouseup () { this.transform.parent = GameObject.Find("FPSController"); this.transform.parent = null; } Please help me fix it Thanks Me
Please don't post an answer to an existing question unless you're trying to answer it.
When you do ask a question, be precise and complete in describing the problem. Unity gives you error messages for a reason, and I'm sure they told you something more useful than your code was "stuffed up".
When including code, please format it correctly.
There are at least three obvious errors in your code: trasform? trnsform? On$$anonymous$$ouseup?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Destroy GameObject A or B 1 Answer
Cube terrain with perlin noise 1 Answer
What is wrong with this script? 2 Answers