- Home /
The question is answered, right answer was accepted
Unexpected char:0xFEFF and Unknown PlayerStateController?
Script for 0xFEFF:
public var bulletPrefab : Transform;
public var bulletSpeed : float = 6000;
function Update () {
if (Input.GetButtonDown("Fire1")) {
if(!bulletPrefab || !bulletSpeed) {
Debug.Log("[Shoot] 'bulletPrefab' or 'bulletSpeed'is undefined");
} else {
var bulletCreate = Instantiate(bulletPrefab, GameObject.Find("Spawnpoint").transform.position, Quaternion.identity);
bulletCreate.rigidbody.AddForce(transform * bulletSpeed);
}
}
}
And here's the script for Unknown Identifier:
function Update ()
{
PlayerStateContoller();
PlayerAnims();
}
function PlayerStateController()
{
if ((Input.GetAxis("Vertical") !=0 || Input.GetAxis("Horizontal") !=0))
{
if (Input.GetButton("Sprint")&&!Input.GetMouseButton(1))
{
PlayerState = 2;
}
else if (Input.GetMouseButton(1) && !Input.GetButton("Sprint"))
{
PlayerState = 3;
}
else
{
PlayerState = 1;
}
}
else
if (!Input.GetMouseButton(1))
{
PlayerState = 0;
}
}
function PlayerAnims()
{
if (PlayerState == 0)
{
PlayerAnimSec.animation.CrossFade("idleanim", 0.4);
}
else if (PlayerState == 1)
{
PlayerAnimSec.animation.CrossFade("walkanim", 0.4);
}
else if (PlayerState == 2)
{
PlayerAnimSec.animation.CrossFade("sprintanim", 0.4);
}
}
Thank you and please tell me specifically because I just began coding (and not good at it heh) Thanks
Answer by Graham-Dunnett · Sep 15, 2012 at 09:59 PM
The byte order mark (BOM) is a Unicode character used to signal the endianness (byte order) of a text file or stream. It is encoded at U+FEFF byte order mark (BOM). BOM use is optional, and, if used, should appear at the start of the text stream. Beyond its specific use as a byte-order indicator, the BOM character may also indicate which of the several Unicode representations the text is encoded in. (Well, so says Wikipedia!)
Save your script as an ascii-encoded file, or instead as a utf-8 one. These are changes you will need to make in your text editor.
To me it was an ANSI type of format :S I was using Unity3D 4.3.2f1 at the moment.
Obviously not that same code but same error. For all those more than newbies just like me out there. Just copy the code in a .txt document and then save it as an ANSI format or any other that works for you. Then copy and paste in $$anonymous$$onoDevelop.
Any experienced programmer care to explain this error in common language XD, so we untrained monkeys can learn what's what. TY all.
It was utf-8. what any other solutions? o and what do i do with the unknown identifier thanks
@Nihltos85:
utf8 is a compact way to encode Unicode characters so they can be saved to a file / data stream / whatever. Different PC hardware-architectures uses different ways to store numbers which need more than one byte to be represented. This is called Endianness. The x86 compatible family for example uses the little-endian format. Since data (in the form of files or send via the internet) can be transferred to other systems It's difficult to deter$$anonymous$$e the right ordering. The BO$$anonymous$$ (Byte order mark) has been "invented" to tell a reading program how the data has been encoded. However this is not really a valid standard in Unicode. It's better to save the file as a simple ASCII or ANSI text where each character is exactly 1 byte. If Unicode is needed the file should be saved as "utf8 without BO$$anonymous$$" if available.