Can I get the same framerate in the engine and on the browser?

Hey, I am now at my third game with Ready and I can’t help but realize that the physics and frame rate are different in the engine when I test and when I share the games. Is there a way to solve this?

Here is an example of my issue. I make a game using physics and use the function add force up on my object (Similar to Flappy Bird) but when I test in the engine I can cross over 20 feet with 2 flaps, on the webpage after sharing it takes about 8 flaps for the same distance.

The browser does not seem to be the issue, so does the engine allow to limit the framerate to something like 30-60 fps both in the engine and online?

Thank you for the support, I enjoy making games on this engine but testing them is a pain if I have to share the projects to test it :frowning:

1 Like

Hi @Potatobob666 ! The work of physics may be slightly different between playing your project on PC and in WEB - these are the features of the WEB player itself.

There are several solutions to this problem. The simplest of them you can ask the user on what device now he is playing your game, you can do it with the buttons and the counter:

Output three buttons before starting the game.
After the user presses one of the buttons, change the counter value for the desired device.
For example, if the counter value is 1. You use the corresponding event where the physics parameters have the correct physics values ​​for playing on this device.

Example: If - Player/Counter/Set Value/1 and Button/Sensing/Touch Down
Player/Physics/Force Up/25 N

Also, you can come up with more tricky options for automatically detecting the device. For example, let’s try to determine where the user is playing his project, on the mobile or in the WEB?
Here is an example scenario:

Add a new object to the scene
Name it “Device Controller”
Add for him the “Tilt To Move” behavior
Add to it the “Counter” behavior
When the scene starts, make it invisible.
Add 3 new events to determine the device you are using:

1)If Device Controller/Physics/Velocity/>1
Player/Counter/ Set Value/1
Device Controller/Appearance/Set Hidden/Yes

2)If - Player/Counter/Set Value/1 and Button/Sensing/Touch Down
Player/Physics/Force Up/25 N

3)If - Player/Counter/Set Value/0 and Button/Sensing/Touch Down
Player/Physics/Force Up/15 N

Also you can come up with your interesting option. Share your logic on the forum. I think that such an example will be a good help for many other users.

1 Like

Thank you very much for that quick and accurate answer. I will test the option to detect automatically for sure and hope it works as I would rather not ask the player.

It is sad that we have to change a variable according to the build but if there is nothing automatic I will definitely come up with an option. Thanks again :stuck_out_tongue:

1 Like

…No Problem :wink: !

This question interests me as well because I have recently run into the same issue (while trying to calibrate the Pong tutorial game - https://forum.getready.io/t/pong-feeling-retro/1990 ) and because it is one of the classic issues for web developers.

@Ready here’s a question for you, mostly just for my own curiosity : would it be technically feasible to support platform detection in the Ready engine i.e. by offering event conditions something like System/Platform/{mobile,mac,windows,web}

1 Like

I would definitely need it as the game runs differently on each platform so It could help to simplify balancing as well.

For my part I enjoyed the solution provided above for detecting a mobile device but I found no way to differentiate the pc engine and the pc browser without: Blocking the player input when the game start to make some test in the background but this is way too tedious and shady for a simple task.

I really hope Ready can pull this one out ! Cheers

1 Like

System/Platform/{mobile,mac,windows,web}

Thank you @auntiel ! Yes, this is a good solution :+1:, I added it to the task list for the future.

1 Like

Wow I wasn’t expecting that, @Ready, but I’m for sure happy to hear it! If you’re really going to implement it, might I make an amendment to include separating iOS and Android instead of simply “mobile”, and if you really want to go for maximal precision, maybe consider adding specific desktop browsers. The other day when I was pestering you about my pong game I was noticing significant differences between webgl on mac-firefox vs windows7-firefox, and web developers generally find it necessary to code for each OS-browser combination (but you probably knew that).

1 Like

@auntiel - Thanks again! Yes, perhaps we will implement a more detailed separation, although it looks a bit confusing and can add a significant part of the events. We will think about it when we start working for this!

1 Like

HI @Potatobob666 ! Here is a possible solution for identifying a platform between a PC and WEB:

  1. Add any object to the scene
  2. Let’s give it the name “Trigger”
  3. Arrange it for a distance of 1 flap (One jump) for the WEB
  4. Make it invisible at the start of the scene
  5. Create new events:

1)if Player/Position/Is Below Object/Trigger and Button/Sensig/Touch Down and Trigger/Appearance/Set Hidden/No
Player/Counter/Add/1
2)If Player/Position/Is Above Object/Trigger and Player/Counter/Less Than/2
Trigger/Set Hidden/Yes
Player/Counter/Set Value/1
3)If Player/Position/Is Above Object/Trigger and Player/Counter/Greater Than/2
Trigger/Set Hidden/Yes
Player/Counter/Set Value/0
4)If - Player/Counter/Set Value/0 and Button/Sensing/Touch Down
Player/Physics/Force Up/25 N

5)If - Player/Counter/Set Value/1 and Button/Sensing/Touch Down
Player/Physics/Force Up/15 N

@Ready, it’s a tradeoff for sure, and I’m not sure myself at this point what I would prefer. Another possibility for consideration would be to offer multi-level choices to give some options how complex to make platform detection for each game. In other words, the options could be

{mobile,desktop, web, ios,android,mac,windows,mac-chrome,mac-firefox,mac-safari,windows-chrome,windows-firefox}

Then someone making a game could decide, for example, whether “web” is good enough, or if they need different settings for each browser.

1 Like

@auntiel -Yes, maybe!

1 Like