Steady Drop – Log #5

Share:Tweet about this on TwitterShare on RedditPin on PinterestShare on FacebookShare on LinkedInShare on Google+

 

Gyroscope handling

I want to talk a little bit about the first things I developed when I got the idea for Steady Drop. Just from the beginning I had this idea to use the gyroscope data from a mobile device and to do something with it. I started developing a first prototype which uses the gyroscope quaternion given by the “attitude” property and elaborating it to get the gravity direction using euler angles. The class doing all this stuff was (and is) called GyroTilt and for some time the name of the game/project was GyroTilt until I came up with Steady Drop. For a prototype it worked fine, and I started developing the game on top of this logic. At the time I wasn’t testing everything so often on a real device and for a reason or another I finished up screwing part of the logic and all the rotations were broken.

Recently I’ve changed the method to compute the gravity direction by simply getting the gravity directly from the the gyroscope class. This property returns a vector (with magnitude one) with the direction of the gravity in world space. I can take this vector and go on and use it with the rest of the logic which wants only the gravity direction and ignores how it is computed. Unexpectedly this gravity vector is much more stable that the attitude and I think it is not more CPU expensive that the other.

One issue I will have to resolve will probably be the device compatibility, since I’m developing this game for Android, there are hundreds of different devices with different mounted sensors. I haven’t tested my game on different devices yet, so I’m thinking to give the game build to some friends and people who can test it out, a sort of “closed alpha”.

 

Gravity direction, now what?

Ok, now that I have the gravity direction I use it for adding the increasing force (like I said in devlog #4) with its logic ruled by user inputs, and for rotating the object. To rotate the object correctly, I tried in the first place to use the RigidBody rotation caused by the force I add, which is nice but I could not find the right level of responsiveness I want. So I decided to freeze the rotation on the RigidBody component and to apply the rotation manually to the Transform. In this way the rotations are very responsive and the fact that I’m not using the rotation from the RigidBody is not a problem, since the physic system is all custom and ruled from my scripts.

 

Future uses

Since now the gravity direction seems stable I’m thinking to use the gravity for different purposes that can add gameplay variationsRight now the only object that react to gravity is the avatar of the player, what about some special enemy that reacts to gravity? I’m not sure to use the pendulum that I have right now, but I’m thinking a new type of walls maybe, that reacts to gravity. Maybe the gravity can affect some physics parameters of an object or an obstacle. I will decide what to do about this matter in the future, surely after the beta release.
Stay tuned for future posts 🙂

Game developer & designer. Unity 3D lover. Movie fanatic.

Game developer & designer. Unity 3D lover. Movie fanatic.