Jump to content

Image of the Day

#QuestOfDungeons is an old-fashioned dungeon crawler. #ScreenshotSaturday  #PS4share

https://t.co/1mztLegxeN https://t.co/DpYimg3MZb
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

Dynamic gravity vector

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 jbosch   Members   

107
Like
0Likes
Like

Posted 21 May 2011 - 09:34 AM

Hi,


I have a physics engine in my game. I have to set him the gravity vector to initialize it. That would normally be x,y(0,10). Ok, easy one. But what happens if the container is a mobile, and I want to modify the gravity vector according to the accelerometer information? This is, if I give the mobile phone a 90º inclination, the "ground" is now different than in its initiajl state, I want to reflect this, but at any angle, not just 90º movements.


This can be difficult to explain, so I have attached a picture

mobile.png



Any idea?

#2 Hodgman   Moderators   

50164
Like
0Likes
Like

Posted 21 May 2011 - 09:38 AM

Does your physics engine provide a function for setting a new gravity vector? Is the question how to change the gravity vector, or how to figure out what the new vector is?
Take your default gravity vector and rotate it by the desired angle.

#3 jbosch   Members   

107
Like
0Likes
Like

Posted 21 May 2011 - 10:28 AM

thanks Hodgman,


The question is more about how to calculate this angle.

The accelerometer gives me some information. For example, when the phone is landscape, the acceleration (x,y) its (1,0), and when I put the phone in portrait position, its (0,1).



Any idea?

Thanks!

#4 japro   Members   

887
Like
1Likes
Like

Posted 21 May 2011 - 11:16 AM

So the accelerometer always gives you a normalized vector to the "down"-direction? Then just multiply that vector with the magnitude of your g.

#5 jbosch   Members   

107
Like
0Likes
Like

Posted 21 May 2011 - 11:36 AM

So the accelerometer always gives you a normalized vector to the "down"-direction? Then just multiply that vector with the magnitude of your g.



whaaw, you are right. Very simple! I feel dumb now jajaja




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.