I learned according to the official recommended documents. However, this kind of thing will happen at this step. How can I solve it?
It looks like you are calling it on a null object creating the exception.
Could you repro in the playground to confirm ? You should only call this on an existing instance.
Also to reinforce this you may need to call some awaits or callback to confirm your mesh has loaded.
Otherwise, you will very likely get a null.
I haven’t used the playground, how to use the code of multiple files on the playground
How to call wait or callback to confirm that my grid has been loaded? I read the tutorial on the official web page. This situation does not appear in it
return SceneLoader.ImportMeshAsync(null, “./models/”, “player.glb”, scene).then((result) =>{
The then part is the callback once your mesh has been loaded. (unless you are talking about something else?) As for merging multiple files for a playground, you can create different classes and functions all in one file. So you are not going to need to import anything from across files.
OK, OK, I see. I’ve shown it. But now there is a problem. When I first entered the game, the keyboard keys did not respond. I need to move the cursor out of the canvas, click (red arrow), and then click back into the canvas (green arrow). The keyboard keys can be triggered.