Heavy bugs within the 'scene change' functionality


#1

I am currently trying to make a little online storytelling project (well ‘little’ minut-wise but ‘huge’ beneath :-/ cf The exact FPS-conversion from Blender to PlayCanvas? as well). Anyways: I have struck some major issues concerning ‘scene change’, and here are the first two most relevant of them:
A) While launching a set of scenes I experience that the the main time, blurs from one scene to another, where the main time, should be resetting from scene to scene (sometime sound is firing way to early in scene 2, as the time flows over from scene 1).
B) Occasionally I experience that merely clicking on a launched scene can restart the previous scene, without me coding any scripting; to do such action (can it be HTML/DOM interaction related?).


How to load assets runtime
#2

Without the project link or a reproducible small sample, it’s hard to see what the problem is.

Some things to remember about ‘scene changing’

  • PlayCanvas doesn’t have the concept of changing scenes. You start from one scene, additively load another scene and delete the Root object of the original scene.
  • When deleting the Root of a scene and entities, remember to remove all event listeners to entities, input etc.
  • The scene Root object is not the same as this.app.root. It’s a child of it.

#3

Ok, I will try and tidy up events etc (could have posted example, but I think its ok for now … will try and see if my change-scene buttons from prior scenes can be set turned-off/inactive) + use the root-tip to see if I can split up timers


#4

i concur with Thomas, since about 2017 ive had issues with scene changing, often i wont change or restart scene to save time because the way you load a scene seems excessive, a lot of errors not just with events, but with renderer as well, ill make a test project


#5

ok, yqu … sounds great


#6

In the meantime yaustar :slight_smile:

{hope we are speaking of the same area in regards to what is possible in playcanvas: https://developer.playcanvas.com/en/tutorials/changing-scenes/}

Also while trying to (kind of) set a timer-milestone each time I change scenes, I need the compiler to tell me which scene I am in, for then to get a better overview (this script is put on each of my three scenes):

var RootTimers = pc.createScript(‘rootTimers’);
RootTimers.attributes.add(‘perfHT_count’,{ type: ‘number’, default: 0});

// initialize code called once per entity
RootTimers.prototype.initialize = function() {
console.log(‘First time init NEW SCENE’);
var app = this.app;
};

// update code called every frame
RootTimers.prototype.update = function(dt) {this.perfHT_count++;
if(this.perfHT_count>120){ console.log(‘ROOT timer 120’+this.app.getSceneUrl(this.app.scene)); this.perfHT_count =0; }
};

  • and later control all timed events

#7

ok, while looking deeper into the change-scene example, i can tell that there this a destroy-action, indeed.


#8

I am not sure that this approach is the best way to go about it. If there is some logic to load different scenes, then it can also keep tracking of which scene is loaded at any point.

What’s the problem you are trying to solve?


#9

I have found that the start-up loadtime becomes smaller for my project (realtime 3D-interactive story as also touched upon The exact FPS-conversion from Blender to PlayCanvas?). In that regard it seems like the hierarchy-setup of initiations and destructions ( .destroy() ), works quite good. At least much better than my idea/post of How to load assets runtime, where having the three scenes in one, will result in a much bigger preload-time.


#10

I’m surprised that there is a large difference in startup load times between your 2 scenerios. A good tool to check is the network view in developer tools to cross check what is being downloaded.