Physics objects and VSync and Speed

D

dukemc

Guest
Hi GM Community !

I'm new to GM and just trying some tutorial to learn gamemaker.
I actually looking about built-in physic engine.
I use VSYNC in my project, because i always personnaly like VSYNC in game...
I have two monitor, one 120hz and one other 60hz.

I see that the object are moving faster on the 120Hz monitor than on the 60hz monitor.
I understand this is because such as ROOM_SPEED is define by the VSYNC. (and so i have as much STEP EVENT as the refresh rate of the screen)

So for my NO-PHYSCIS objects i applied DELTA-TIME such as i readed in this forum. --> It's OK.

But for my PHYSICS object, i can't find how to make them have stable speed regarless of FPS speed ? (which i can't prejudge because it will be 30 fps on low spec PC or 240 fps on high end gaming set...)


Is it possible to use built-in Physics and VSYNC in the same project ?
Any idea on how get stable PHYSICS speed regardless of FPS ?

I readed some tips about "FrameSkipping" about to dissociate drawevent and stepevent, but i didn't think it can seriously resolve all case ?


Thanks !
 
D

dukemc

Guest
Thank you MusNik, i recently bought your Fixture Editor and it's a cool time saver tool ;)


About my problem, i tried both function.
at the beginning i was thinking it does nothing at all.
but with more tests i saw that physics_world_update_speed only apply on object create after it's call !

I mean :
- set World Update Speed to 300
- create an instance of an ObjectA with a local XFORCE of 1000
- set World Update Speed to 120
- create a second instance of the same ObjectA with the same local XFORCE of 1000

The second instance is moving faster than the first !
So it seem's to be great about to fix the physics speed according to the VSync FPS, but because it doesn't apply to existing instance it doesn't seem to be able to protect of "FPS drop" during the game (like Delta-time is able for non physics object).
Does anyone know how to apply the new physics_world_update_speed to existing instances ?

(Furthermore, i didn't understand why at the moment, but the taller the World Upate Speed is, the slower the instance of object is moving.)

Thanks again,
 
D

dukemc

Guest
Yes i will :)
It solve the problem when the game start.

But it doesn't solve others cases that can happen on user's computer such :
- fps dropping (cpu overcharge or else) during game is running
- changing monitor during game is running (like i do by drag/droping game's Window from 120 hz to 60 hz monitor)
- etc.

For exemple in case of FPS/Step Drop during game is running, my No physics will be "time sync" via Delta Time, but not the physics one --> so they will be desynchronised.
In my project i have No-physics and Physics objects, so i need to be sure they will stay "synchronised" or it will make bug or, for sure, break the gamer's experience.

That's why i try to know if it is possible or not with GameMaker before invest tens or hundreds hours in my project :)
Otherwise i must think to find or develop myself (uh?!) another "phycis engine like" that is capable of stable speed regardless of fps/step.
It would be a shame because for the rest the built-it engine seems very interesting.

But i hope their is a solution !
 
D

dukemc

Guest
With new eyes this evening it's seem simple in fact.
I make few tests to apply a delta_time to the physics velocity each step and it seem to work well.
I will make further tests this week-end (because i'm wondering about consequence on collision for example...)

here the few code i quickly test. It need lot of improvment.
but in my little test project my object course the room in 7,160 seconds each in the 120 hz or 60 hz, even with low FPS dropping.

Create event of the physics object (8333 because the game is designed at 120 step)
Code:
y_last_delta_time = 8333;
step event :
Code:
if phy_linear_velocity_x <>0
{

        if y_last_delta_time<>delta_time
        {

   
            var y_modifier = (delta_time/y_last_delta_time)
            phy_linear_velocity_x = phy_linear_velocity_x * y_modifier;
            phy_linear_velocity_y = phy_linear_velocity_y * y_modifier;
            phy_angular_velocity = phy_angular_velocity * y_modifier;

   
            if abs (y_modifier-1)>0.2 {
                show_debug_message(y_modifier)
            }

            y_last_delta_time = delta_time

    }
}
 
Top