background
I have a local copy of playcanvas 0.192.0 which is being served via a nodejs web server, together with
the minimal example of a spinning cube found in the sources. I made a few small changes.
I am trying to to play around with the first-person-movement script, which I found here https://playcanvas.com/editor/scene/329712
problem
I have tried to simply add the script to the head of my page, but the script isn’t added to the ScriptRegistry
and I am entirely sure whether it is supposed to; app.scripts.list() returns an empty array.
Beside including the movement script, I have a construction like this
player.addComponent("script", {
scripts: [{
url: 'first_person_movement.js'
}]
})
And I am wondering, what’s the purpose of url ? I see no outgoing request, so I assume playcanvas
doesn’t request this for me?
Now I am at the point where I have something like this
var controller = pc.createScript("first_person_movement");
player.addComponent("script");
player.script.create("first_person_movement");
I now get something back form app.scripts.list(), but it is not the actual function of
first-person-movement.js I am looking for.
I am trying to move a player entity, which has all the required components to be moved by
the first-person-movement script, my main problem is that I don’t receive any errors or see any requests.
questions
- Should url request the script for me, or do we have to make our own xhr function?
- Should a script included to the page add itself to the ScriptRegistry?
- What is the correct way to apply a script to an entity? because it seemed really straightforward here:
https://playcanvas.github.io/#camera/first_person/index.html