Thanks for the suggestion to help with my project, I will think about it and give feedback. I will also mean participation in the development of joint projects.
Thanks a lot @MasalovAndreey.
Without a link to the project, it’s a bit difficult to say what exactly the problem is. My guess is that is a first frame issue where the app may be initialising everything in the first frame which takes a little while (or long enough to see the initial position to be).
You can get around this by disabling the camera in the project and then enabling it at run time after the random positioning.
Thank you for the proposed method. In my project, the tilt angles of the weapon and the player’s movement is based on the direction vectors of the camera and camera angles. I turned off the camera and made a check on its state (on or off) in functions where its coordinates or angles are used. After that, I used the
setTimeout() function to turn on the camera after working out all the initialization functions. This method works, but only after loading, for a short period of time, a black screen is displayed. I think that can add a second camera and display, for example, a countdown timer before the start of the match, after which you can switch cameras. Thanks again.
The link to the video.
The black screen is displayed since there is no active camera. I think your proposed method will work perfectly.
The project link is more useful as it allows people to look over the existing project/fork it to do a proper fix.
At the moment I’m only guessing what the problem is and can give a ‘catch all’ solution.
There’s a postInitialize function that you could use instead of timeout which gets called after all initialize functions
I found that the problem with what can be seen as a player moves, occurs in Google Chrome browser. In Mozilla Firefox, everything works correctly. I tried using the
postInialize() function, however, it did not work in my case. After launching the scene, I also saw the player moving to a random starting position in the Google Chrome browser. I also tried using the zero delay
setTimeout() function. It works, however, a black screen is displayed for a few hundredths of a second, which looks terrible.
I solved the problem with the second scene, which contains the game menu. After loading the scene with the game I check, if the player is in a random position and if so, then I turn on the camera. This works in all browsers.
If you start this scene now, you will see how the player is set to a random position in the Google Chrome browser, since there is no transition between scenes. In Mozilla Firefox browser, everything works correctly.
There’s a browser checker that’s quite easy to use.
Thanks for the link and help, I really appreciate it.
I thought about it, that I can check on which browser the game is running and execute the corresponding code. However, I decided that since there is a way to get around the problem through the second scene, it is better to use this method. If you do additional checks, it’s extra code. In addition, I ran the script from your link, and it was false for the Google Chrome browser, since
window.chrome.webstore is no longer supported in Google Chrome since version 71.