3

I have recently taken an interest into unity, and as I guide a chose a playlist from youtube. I have installed the

Unity 5.6.4

16 Oct, 2017

version as well.

Now, I encounter an error when I try to add a script to an object.

In the tutorial: here , this happens from 11:40 to 13:40.

Basically, as a summary, he is writing a script in js and then attaches it to an object. Now, I have followed the exact steps as him, but it does not work for me.

I write the same script as him, in JS:

jsScript

then add the script to the object. But then, on the object, I should get a target option, like he does:

enter image description here

However, I don't get this option on my object:

enter image description here

The error I get in the console is this:

Assets/Scripts/PickUp.js(1,386): BCE0044: unexpected char: 0xFEFF.

And this is the actual script:

var target : Transform; 
function Update () { } 

function OnMouseDown () 
{ 
    this.transform.position = target.position; 
    this.transform.parent = GameObject.Find("FPSController").transform; 
    this.transform.parent = GameObject.Find("FirstPersonCharacter").transform; 
} 

function OnMouseUp () 
{ 
    this.transform.parent = GameObject.Find ("FPSController").transform; 
    this.transform.parent = null;
}

Now, I've heard that it is not the most efficient, but at this point, I don't really care about that, I just want it to work.

3
  • maybe a codepage problem? JS in UTF8 and Unity wants smth else or vice versa? - just guessing Commented Nov 28, 2017 at 7:17
  • 1
    0xFEFF is probably a en.wikipedia.org/wiki/Byte_order_mark . Can you open an editor that shows these kinds of characters (such as Notepad++ with the correct settings). Are there any 'funny' characters, specifically at the end of the file? Commented Nov 28, 2017 at 7:17
  • 1
    you should use c# ;) Commented Nov 28, 2017 at 7:19

1 Answer 1

4

Try to save your script using UTF8 - no BOM (ByteOrderMark). If that does not help, save as Ansi and try that - or read up what unity wants :)

enter image description here

Unity3d Issue Tracker: textassets-encoding-prefab-with-utf8-bom-encryption-is-corrupted it might be related.

This UTF-8 as default in Unity3D new script? was not solved unfortunately.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.