x


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)

more ▼

asked Jan 10 '11 at 12:02 AM

Bat2k gravatar image

Bat2k
1 1 1 1

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

Jan 10 '11 at 01:26 AM Peter G

It doesn't help.

Jan 10 '11 at 09:57 AM Bat2k
(comments are locked)
10|3000 characters needed characters left

2 answers: sort oldest

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?

more ▼

answered Jan 10 '11 at 12:51 AM

Mike 3 gravatar image

Mike 3
30.5k 10 65 253

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...

May be this is the clue?

Jan 10 '11 at 08:04 AM Bat2k

Yup, the code compiles fine for me changing Transform to transform

Jan 10 '11 at 08:27 AM Mike 3

Strange, but I've changed transform to Transform because of error

Assets/Movement.boo(13,9):BCE0005: Unknown 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?

Jan 10 '11 at 09:43 AM Bat2k

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.

Jan 10 '11 at 09:46 AM Bat2k
(comments are locked)
10|3000 characters needed characters left

Ok, I recreated the project from scratch and it just works. No more variable/Transform issues.

more ▼

answered Jan 10 '11 at 10:17 AM

Bat2k gravatar image

Bat2k
1 1 1 1

Perhaps you could edit your question by including what you did to solve it so people do not have to read all the posts ?

Mar 30 '11 at 11:01 AM Ippokratis

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 Movement. As a result, it's no longer in the class's scope and _speed is undefined.

Dec 05 '11 at 03:16 AM ironmagma
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1949
x198
x70
x70

asked: Jan 10 '11 at 12:02 AM

Seen: 1166 times

Last Updated: Dec 05 '11 at 03:16 AM