Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Physics Gravity question

Author
Message
Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 19th Apr 2012 01:11 Edited at: 19th Apr 2012 01:12
What is the default value of SetPhysicsGravity()?

I can't find it listed on the command description page.

My tests indicate that it's 0x and 75y.

I would like to know for sure though so after I disable gravity I can set it back to the default value.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 19th Apr 2012 01:23
The default value is 10 meters per second, but to use SetPhysicsGravity() to reset it to 10 meters per second you'll have to take your physics scale into account. For example a scale of 1.0 then you can do SetPhysicsGravity(0,10), but if you are using the default scale of 0.2 you'll have to do SetPhysicsGravity(0,50). Think of this value as pixels per second and the scale value says there are 0.2 meters per pixel, so 10 meters = 50 pixels.
Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 19th Apr 2012 04:11
Quote: "The default value is 10 meters per second, but to use SetPhysicsGravity() to reset it to 10 meters per second you'll have to take your physics scale into account. For example a scale of 1.0 then you can do SetPhysicsGravity(0,10), but if you are using the default scale of 0.2 you'll have to do SetPhysicsGravity(0,50). Think of this value as pixels per second and the scale value says there are 0.2 meters per pixel, so 10 meters = 50 pixels. "


Hmm... I am using the default scale, however setting it to 0,50 with the default scale does NOT return it to normal. Using 0,75 returns it to what appears to be normal, and if it isn't dead on, its VERY close.

0,50 is not even in the ballpark, that's more like being on the moon.

You might want to take a look at the numbers, there could be a bug in there somewhere.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 19th Apr 2012 05:19
The only explanation for that is if you are using percentage coordinates as then the Y axis is stretched further than the X axis and you need to set the Y value higher than normal. Percentage coordinates still mess with my head (and I wrote them!) so I always set a virtual resolution.
Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 19th Apr 2012 06:43
Quote: "The only explanation for that is if you are using percentage coordinates as then the Y axis is stretched further than the X axis and you need to set the Y value higher than normal. Percentage coordinates still mess with my head (and I wrote them!) so I always set a virtual resolution. "



Aha! I did not realize using the percentage system would affect the SetPhysicsGravity() command.

You are correct, I am using the percentage system, with an aspect ratio of 1.5 to 1, which completely explains the 75 vs 50 setting for the gravity.


So my conclusion would be that the proper way to set gravity to normal for anyone using the percentage system would be...

SetPhysicsGravity(0,50 * GetDisplayAspect())


Or more to the point, to have any gravity setting behave like it would for a virtual resolution, just multiply it by the aspect ratio as above.

Thanks for the explanation Paul.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th Apr 2012 12:40
I always use either a constant or global value for aspect ratio as I almost always use the percentage system.


That way I don't need to use the full command every time. I do all of my sizes based on the width and either multiply or divide by "aspect" to get a logical value. It's confusing at first but the more I use it the more I like it. It allows for an easy swap between landscape and portrait although I haven't properly taken advantage of that yet.

Login to post a reply

Server time is: 2024-05-04 20:22:08
Your offset time is: 2024-05-04 20:22:08