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