Big city testing

So far, everything is pretty similar. Then there will be scenery, traffic and pedestrians. Press WASD to drive and R to listen to music. Bugs may be present.

https://intheaction55555555555.on.drv.tw/1InTheActionFirstSample/

Picsart_23-04-20_21-33-34-871

2 Likes

I have a number of CORS policies errors and as a result, cannot drive. WASD is not reacting. :cry:

1 Like

I always have problems with the keyboard, although I do it according to examples from the Internet. I’ll try to fix it. So far, try to run it from your mobile, it definitely works there

Did you use the keyCode for the input (for keyDown), something like:

scene.onKeyboardObservable.add((kbInfo) => {
        switch (kbInfo.type) {

        //on key press
            case BABYLON.KeyboardEventTypes.KEYDOWN:
                switch (kbInfo.event.key) {
                    case "w":
                    case "W":
                    case 87:
                        console.log ("forward down");
                    break
                    case "s":
                    case "S":
                    case 83:
                        console.log ("backward down");   
                    break
                    case 65:
                    case "a":
                    case "A":
                        console.log ("left down");   
                    break  
                    case 68:
                    case "d":
                    case "D":
                        console.log ("right down");
                    break  
                }
            break;
        //on key release
            case BABYLON.KeyboardEventTypes.KEYUP:
                switch (kbInfo.event.key) {
                    case 65:
                    case "a":
                    case "A":
                        console.log ("left released");
                    break  
                    case 68:
                    case "d":
                    case "D":
                        console.log ("right released");
                    break 
                    case "w":
                    case "W":
                    case 87:
                        console.log("forward released");
                    break                                                          
                    case "s":
                    case "S":
                    case 83:
                        console.log("backward released");
                    break                                                    
                }
            break;
        }
    });

Try to play again

Nearly :grin: Already better. Now I can turn left and right, but the ‘W’ key sort of conflicts with ‘full screen’ and pressing ‘S’ very quickly pushes me back into the water and from there I only go in circles(on water).


It also seems to me that the sensibility when pressing the key is way too high.

Edit: It looks like pressing any key, pushes the engine to full screen. Even when calling the console, I get pushed to full-screen. If I was you I would add a full-screen/windowed button, eventually coupled to a keypress to toggle full-screen. Calling full-screen in the engine loop is kind of not a good idea if you ask me. Might be ok on mobile but not on desktop.

Edit1: May be you could also make a more user-friendly link, could you? I wanted to quickly check on mobile but it takes me half a day just to figure the link.

I got tired of looking for normal free hosting, and put the files on Google drive. And he has only such a link. I can only change a small part

Thanks for the advice. I think putting fullscreen mode on the main control keys would be better

1 Like

Reminds me of GTA! :grin:

I did get this error on the splash screen. The map loaded, but I wasn’t able to drive either.


Reloading of the page will help. The sound error does not always occur, only with some one. But it blocks the controls script. I’m still thinking how to get rid of it

And yes, this is a map from gta1, Liberty city. I have redrawn it to fit my needs

These are all these CORS (fancy) policies issues. It might come from the hosting. You should also ensure all your links are https. The sound is also restricted on load and there are some tips to make the sound on onload (without generating a CORS policy error). Problem is once you hit one of these, the rest of your script is affected. Given the time and efforts you obviously put into this, I think it’s sad to face all the problems you are facing now because of hosting. After all, you want to be able to share the result of your efforts, don’t you? I know money is money, but there are some very cheap hosting you could get for just 3 or 6-month for a start. If I was you, I would consider having my own server (of course, my opinion only).

1 Like

The link I provided seems to start with “https”.
It’s strange to me that out of 12 similar files, only some are not uploaded. Logically, either all of them should be loaded, or none