I did a small project to get use to PlayCanvas and Javascript which where both new to me and to prepare for a much bigger project.
PlayCanvas findings after first (small) project:
In general I like it very much. I like the Entity-Component architecture. And I like that you can do almost anything using Javascript. I just scratched the surface but I’m sure a lot of things are possible.
All feels very solid. I had zero crashes. Well, the iPhone crashed because I used to many big textures. But that is off course not a PlayCanvas problem.
Graphics quality seems to be quite good.
What I found confusing is what object types you are dealing with. Sometimes you have a reference to an Entity or GraphNode and sometimes it is a script you are referencing to. (findByName() returns a reference to GraphNode in stead of Entity)
When I added 1000 entities to a scene, the framerate got really low. So performance is a thing I’m concerned about.
General questions for next (bigger) project:
Where should I put my scripts that are not attached to any entity. I will have a lot of supporting Javascript classes to make the game. Should I attach them to the root? Or just place them in the script folder?
My next project will need hundreds or thousands of objects. Most of them moving. Are there some ‘good practice’ tips for PlayCanvas and or Javascript so that we get the most performant code? Is for instance the extraction of a script reference from some entity a slow operation? Will it be better to do that once and remember the reference if possible?
And what is that fastest way to store and access variables? Are instance variables slower than global variables? How to deal with arrays to have fast access? What is the underlaying storage technique? Does it need to move the whole array when growing in size (like a vector in C++)? If so, can you reserve memory for some number of items so that it does not has to move in memory when growing?
Are there documents describing underlying techniques so that you can make better choices?
Does PlayCanvas assumes some unit size? Will a delta of 1.0 in position correspond to 1 meter? Or is this completely up to the user? Sometimes deep in an engine there are assumptions about this. I guess it is important for the physics simulation for instance.
What is the best (fastest) way to communicate between scripts attached to different entities?
A: using SomeObject.attribute.add(‘refval’, {type: ‘entity’) and set refval to some other entity? Then getting the script reference from this?
B: searching for the entity using app.root.findByName() and getting the script reference from this?
C: using events?
Which documents would you advice to study to prepare for the bigger project?
Thanks PlayCanvas team for this amazing engine!
I’m looking forward to start my bigger project