- Home /
Block Placing script error
I have found this script online and I saw it being used in a video working fine. I am trying to make a minecraft parody.
when i tried to use it, Assets/Place Script.js(15,52): BCE0044: unexpected char: 0xAD.
please help.
var range : float = Mathf.Infinity; var hit : RaycastHit; var BlockTexture : Texture;
function Update() { if(Input.GetMouseButtonDown(1)){ Build(); } }
function Build() { if(HitBlock()){ var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.renderer.material.mainTexture = BlockTexture; cube.transform.position = hit.transform.position + hit.normal; } }
function HitBlock() : boolean { return Physics.Raycast(transform.position, transform.forward, hit, range); }
Answer by robertbu · Mar 24, 2013 at 08:07 PM
These errors occur when characters with higher values (likely above 128) find their way into the script. You can see the offending characters in many word processors like Word, or any program that displays binary data. The fix is to delete and then retype the offending line. Often there will be several lines in a file that have that problem. To find the line, double click on the error in the Unity Console, and the line with the error will be highlighted in Mono.
wait, my line was line was 15. I just delete it and retype it?
it is just that I just did and nothing happened. please help.
Im sorry but nothing has happened when I retyped the code
Here is a cleaned up copy of the code:
var range : float = $$anonymous$$athf.Infinity;
var hit : RaycastHit;
var BlockTexture : Texture;
function Update() {
if(Input.Get$$anonymous$$ouseButtonDown(1)) {
Build();
}
}
function Build() {
if(HitBlock()) {
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.renderer.material.mainTexture = BlockTexture;
cube.transform.position = hit.transform.position + hit.normal;
}
}
function HitBlock() : boolean {
return Physics.Raycast(transform.position, transform.forward, hit, range);
}
Oh yes! Thank you so much. Can you explain what you did? if not, that's alright. Thank you!
I did just as I indicated to you in my answer. I loaded the script above into $$anonymous$$ono, in Unity I got the error. I double clicked on the error to take me to that line. I opened up a new line. I typed in an exact duplicate of the line. I deleted the original line. If this answered your question, click the check mark next to the answer.
Your answer

Follow this Question
Related Questions
UV mapping 5 Answers
Realistic block placing/building 1 Answer
Blocky terrain optimization 1 Answer
[Script] place block(prefab) align to grid like minecraft? 4 Answers