I have a scene that, after loading, should start with a cutscene. I made the entire dialogue in a single audio file that auto plays.
You’re supposed to get to the scene via a button.
The problem now is that, when I switch the scene, the sound already starts to play just before the scene with the cutscene is actually visible and starts to play. That causes a delay between audio and the cutscene.
The code for switching the scene with the button:
var StartButton = pc.createScript('startButton');
StartButton.attributes.add("sceneName", {
type: "string",
default: "",
title: "Name of the scene to be loaded"
});
StartButton.attributes.add("rootEntity", {
type: "entity",
default: ""
});
// initialize code called once per entity
StartButton.prototype.initialize = function() {
this.scene = this.app.scenes.find(this.sceneName);
this.app.scenes.loadSceneData(this.scene, function(err, sceneItem) {
if (err) {
console.error(err);
}
});
this.entity.button.on('click', function(event) {
// Aktuelle Szenenhierarchie vom Speicher löschen
this.rootEntity.destroy();
//Neue Szene und dessen Einstellungen laden
this.app.scenes.loadSceneHierarchy(this.scene.url, function (err, scene) {
if (err){
console.log(err);
}
});
this.app.scenes.loadSceneSettings(this.scene.url, function (err, scene) {
if (err){
console.log(err);
}
});
}, this);
};
Thank you so much in advance