Runner tutorial ERROR:GAMEOBJECT: Component '/level/ground/controller#script' could not be found when dispatching message

I am following Runner tutorial and now is at STEP 6 and got stuck with the following error from controller.script:

ERROR:GAMEOBJECT: Component '/level/ground/controller#script' could not be found when dispatching message 'set_speed' sent from main:/level/controller#controller

This is my project structure:

I could not figure out what is causing the error.
Can you help point out the cause?

Thanks.

Im not sure exactly what’s wrong (because I never have done the tutorial) , but are you sure that the script is attached to the controller.

I would add print(msg.url()) to the platform script in init(self) to get the id and see if it really is there.

Hope this helps :slight_smile:

1 Like

I have to use full path like this:

msg.post("main:/level/controller#controller", "set_speed", { speed = self.speed })

I’m not sure why what is given in the tutorial is not working.

In your screenshot you post to “ground/controller#script” but the error mentions “/level/ground/controller#script” and then you say:

What if you post to “/level/controller#controller”? Is the id of the script component “controller” or “script”?

1 Like

I posted to “/level/controller#controller” and it worked as well. It is because of the component name is controller and the ID is controller as well. See my screenshot below:

1 Like

I just went through this part of the tutorial and it appears the new editor has maybe changed how to access components with messages? The screenshot below shows the properties of ground.script that we are trying to message:

The thing to note is there is a property named “Url” which contains an unchangeable value derived from the game object ID and the script ID (controller#ground). I used this component name in controller.script.

function init(self)
	msg.post("ground/controller#ground", "set_speed", { speed = self.speed })
end

No, it works just as before. The “URL” property is a help to see the address of the component in its current context. The absolute and relative addressing works just as before.

I think that the problem you have encountered is because the default id of a component is different in editor 2 than 1. If you add a script component from file “controller.script” the old editor would suggest the name “script” whereas the new one suggests “controller”. The tutorial should be updated to reflect that.

4 Likes

“ground/controller#ground” is what works.
“ground/controller#script” (what is still in the tutorial) throws an error, but still seems to work.

edit:
I’ve found that almost? all the scripts references as #script throw errors and need to actually be named (i.e. ground, controller, hero).

You must use the id that you give the component. If you give the script component id ”banana” you should reference it as ”#banana”, if you give it id ”script”, you reference it with ”#script”.

The default id editor 2 gives a component, if you don’t bother to give it an id, has changed between editor 1 and 2. The tutorial needs to be updated to reflect that.

1 Like

Right. Well I’ve finished it, and since it’s been a month or so since the last post in the thread, I figured I’d mention that it is still not right. So someone needs to take a few minutes to fix it as it is likely to be the first tutorial a newbie will do.

Since there is two different controllers in the project, one for each of ground.collection and level.collection I also spent some time trying to decipher if that was the problem, before simply searching for the entire error message to get to this thread.

With that in mind I do not think I will ever willingly use an id such as #script, and I would probably name those controllers differently - maybe that’s part of the lesson haha.

1 Like

After a frustrating couple of hours doing and re-doing this tutorial, I finally found this thread and answer. Just thought I would bump this… It would be good if someone updated the tutorial with the correct script reference.

Done. The tutorial source can be found here:

If you find anything else that isn’t right then please submit a PR or open an Issue

1 Like