Yes if you await
then the function must be async
It will return a promise.
Yes if you await
then the function must be async
It will return a promise.
It getās tricky in loops a ālittleā
async function blah() {
await Promise.all(this.fireWorks.map(async firework => {
await Promise.delay(Math.random() * 500);
return firework.blastOff();
})
}
Thatās returning a promise and using one, itās just an example. Iād probably await firework.blastOff inside to make it clearer. But this is just as valid.
Very interesting I will definitely use promises and ES6 functionality. Good to see I have a nice mixed bag of async functionality to use now. Feels a lot more dynamic and more like proper development.
Just being able to google something you want and then typing npm install --save SOMETHING
and getting fully tested code, immediately integrated is really fantastic. I did this with path finding recently and probably 20 times a day with little utility things.
what was the path finding module you used ? A* or navmesh?
Well I took one that has a bunch of A* Djikstra etc and modified it to make a basic mesh out of the visibility of waypoints using raycasts. So it forms a navmesh (so itās not grid based A* any more, itās graph based)
Excellent. Very cool!
Am i correct that once i locally serve my development code through loading screen, I cannot use code that is written within the playcanvas web editor?
Getting a bunch of errors for missing files for example:
playcanvas-stable.dbg.js:29438 GET http://localhost:8081/PlayerMovement.js?id=7015987
which understandably makes sense, but does this have to be the case for every file or just the ones with the asset id specified in config.json?
Yes the idea is that you put all of your code in that project. If you donāt want to do that, take a look at loading_screen and just allow certain things to be loaded remotely⦠i.e. check for main.build.js or something.
That sounds about right. Thanks. Iāll be picking ES6 i reckon.
I signed up to the forum just to say this:
Your work addresses every single reservation I had with playcanvas (which I find otherwise to be an amazing toolbox).
I hope your solution still works, will know more tonight.
Please keep it alive!
Do you get any errors in the Developer Console of the browser?
Iāve been following your great work since the times of Unity (3?) and your level serializer.
Here you are again, solving the same issues i encounter, yet again.
Great job, works great and fully enables the npm ecosystem, which as a node and hybrid app developer iāve been wanting to achieve for quite some time with PlayCanvas.
Thanks for your contributions!
Are you by any chance using the loading screen way of doing this?
Iām doing it with a separate file and Iām suspecting that may be my problem.
(I have deleted my previous posts because they were getting more confusing than useful)
I am using the PC script way of redirecting to localhost and I canāt get it to work.
No error messages in console (I have commented out the console.log on update in example.js to reduce noise).
The script Iām loading to redirect to localhost.
The script load order, with local.js first.
But still no request to localhostā¦
What am I doing wrong?
It seems you are using Scripts 2.0 where that workflow wonāt work. The local
query parameter is only used using the legacy script system.
Had the exact same issue. Solved it by using a browser plugin to redirect the script request to the local server (Redirector for firefox, i think Switcheroo redirector should work for chrome).
@vaios Makes total sense now.
Seeing as how recent this solution was I thought patching the loader was a workaround for this.
Is there any real disadvantage to using the old script method?
The ES6 stubs donāt look any more noisy than the Script2.0 stubs.
@FREEZX Thanks a ton, Iāll check it right out as soon as I get a spare minute
Thanks everyone for the kind and helpful welcome, youāre awesome!
Sorry all, been away.
So local does work with scripts 2.0 if you use my thing to insert into the loading screen a thing that handles that.
@whydoidoit I donāt have the loading screen method available, so I tried your script method (from exerpt.js, see the screenshots I attached), and I canāt get the redirect to the local server to work.
I have added a couple of console.log()s to your script, one at the top, to see if it gets parsed, one in getFileUrl() to see if it gets invoked at all.
It appears that pc.Asset.prototype.getFileUrl() is not called, or has already been called by the time the script gets to patch it.
Maybe thatās a side-effect of using Scripts 2.0?
Or am I missing something obvious?