- Home /
Can't compile script from Scripting Tutorial (translated to Boo)
Hi, I can't compile the following code inside Unity editor (unity 3.1 free, windows 7 HP). It says:
Assets/Movement.boo(11,60):BCE0005: Unknown identifier: '_speed'. Assets/Movement.boo(12,58):BCE0005: Unknown identifier: '_speed'.
I can't understand what's wrong with it...
import UnityEngine
class Movement (MonoBehaviour):
public _speed = 5.0
def Start ():
pass
def Update ():
x = Input.GetAxis("Horizontal") * Time.deltaTime * _speed
z = Input.GetAxis("Vertical") * Time.deltaTime * _speed
Transform.Translate(x, 0, z)
Have your tried declaring the type? I don't know much about Boo, but do you need a type i.e. _speed as single = 5.0F
Answer by Mike 3 · Jan 10, 2011 at 12:51 AM
Your code as is is fine except the last line, which should be transform instead of Transform.
Not entirely sure why it's complaining about _speed - try relaunching unity perhaps?
Removing _speed references brings back an error that I need to have instance of Transform (e.g. transform) to get access to non static member Translate. Weird...
$$anonymous$$ay be this is the clue?
Yup, the code compiles fine for me changing Transform to transform
Strange, but I've changed transform to Transform because of error
Assets/$$anonymous$$ovement.boo(13,9):BCE0005: $$anonymous$$ identifier: 'transform'.
No I got an error that an instance of Transform required to have an access to Translate method. This is expectable.
But the error with transform/Transform may be the clue...? It seems that I'm missing something not related to the code itself...
By the way since my code is ok, did you manage to compile it in your enironment?
Thank you, I'll try to experiment a little bit more. I can remember that there was no Transform issue before I added members of the class. I'll keep you posted in case I find what's wrong.
Answer by Bat2k · Jan 10, 2011 at 10:17 AM
Ok, I recreated the project from scratch and it just works. No more variable/Transform issues.
Perhaps you could edit your question by including what you did to solve it so people do not have to read all the posts ?
I'm almost certain this problem was caused by a bug in Boo where it will not alert you of mismatched whitespace. Odds are, he was using spaces to indent one part (probably copy/pasted) and tabs to indent the last function [or vice versa]. Boo interprets this as Update being a standalone function — not a method of $$anonymous$$ovement. As a result, it's no longer in the class's scope and _speed is undefined.
Answer by aidenkael · Nov 12, 2013 at 01:24 AM
I always have this problem. In Boo, I never set a public or private before a variable as this has ALWAYS caused compile errors. In my opinion Boo is a broken language, and I would switch to c# or JS unless you have to use Boo for some reason. In addition to better support and resources, they can also aid you if you ever decide to be a computer science major or get a programming job.
Your answer
Follow this Question
Related Questions
jumping error!? 4 Answers
I have an error while building the game 1 Answer
I got a major question 1 Answer
CharacterDamage script semi colon error. 1 Answer
Need some help with my Gravity Gun, New to Scripting. 1 Answer