This project is read-only.

Updating Gravity Direction based on marker

Jan 28, 2010 at 6:26 PM

                  Hey all, I'm trying to create a labyrinth type game (moving a marble through a puzzle, avoiding holes, etc.) using Goblin's marker tracking system. I've modified Tutorial 8 so that the sphere has physics applied to it, but I'm having trouble figuring out how to have the ball react to which way I'm turning the marker. I came up with the idea of getting the marker's rotation values and updating the gravity direction that way. I.E. when the marker is rotated 20 degrees to the right, the direction of gravity changes 20 degrees to the left, that way gravity is always pointing down relative to the viewer. My only trouble is the application of this. How would I go about getting the marker's X & Y rotation, and updating the gravity?  Any and all help is appreciated! Also, if anyone knows of another way to accomplish this, please let me know. Thanks!

Jan 28, 2010 at 6:56 PM
Edited Jan 28, 2010 at 6:57 PM


Actually one of the projects i'm working on is exactly the same you describe above.. You can see an initial video on my blog: . I have, since, added walls and obstacles.

What i decided to do is: get the rotation of the marker and then apply a force to the ball to the direction the marker is rotated.. That way you don't have to change the gravity.

Jan 28, 2010 at 7:23 PM

So, you just apply a force equal to the direction and amount of the marker's rotation?


Jan 28, 2010 at 10:29 PM

Not exactly equal.. I multiply each component (X, Y)  with a constant value, because the value of rotation is a very small number to have an effect on the ball. This depends on the mass of your ball and how "responsive" you would like the ball to be. You can experiment with different values to see what suites you best.

I don't know if this is the best approach to the problem but it works great :)

Feb 2, 2010 at 10:00 PM

I'm trying to do something very similar and am VERY new to this - does anyone know where there is some sample code for a similar game? A labyrinth tutorial or something?   I can't find any example code anywhere and am struggling a bit.



Feb 5, 2010 at 9:16 PM

Specifically - I'm looking for an example of how to convert rotation (quaternion) to direction (vector3).  There doesn't seem to be a direct conversion to determine the direction based on the rotation.    I've tried this with both applying force and gravity direction.  No matter which approach we take, the same quaternion --> vector3 issue remains.  Any help?