Hello @Ozden_Delibas! Did you try to debug your onPress function? You can use the console of your browser for that. I suggest to start with the console.log below.
To open the console in Chrome, use the keyboard shortcut Cmd + Option + J on a Mac or Ctrl +Shift +J on Windows. As an alternative, you can right-click on the webpage and click “Inspect” to open the developer console. Click the “Console” tab in that window.
Yes, that’s correct. The last part (after the warnings), is the result of your console.log. You can see it has find an entity with the name ‘Root’, so that part of your script works as expected.
That way you have to debug all steps of your script to find out where it’s going wrong. If you share a link to the editor of your project I can take a look later today.
@Ozden_Delibas I think our friend means that, while random paths are created with the “.clone()” function in Scene-1, it means that the cloned objects do not disappear when the ball hits an obstacle on the road or falls to the ground. How do we destroy cloned objects? He asks what is the reason for this.
With the cloned objects, are you adding them to the scene root or the app root?
Adding them to app.root adds it to the application root node but the scene root node is a child of the app.root.
So when the scene root node is destroyed, the clone entities that get added to the app.root don’t get destroyed because they aren’t a child of the scene root node.
TLDR, instead of app.root.addChildfor clones, try this.app.root.findByName('Root').addChild