Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
The Maths behind the gravity effect of planets in angry birds space is far different from the actual equation of gravity of a real planet.
The Eluding Gravity Equation
When i was programming my first game "Tank in Space" ( which is about manuvering a tank in space like in "A-Team"), i wanted my tank to orbit the Planet. I searched many sites to see how it was implemented in Angry Birds Space, but none could provide a clear picture. After several experiments i succeeded in finding the equation which makes any object revolve around a planet irrespective of speed of arrival inside gravity field.
You can check out my implementation in my game
https://play.google.com/store/apps/details?id=com.jaykalabs.atank1free
The Implementation
The normal equation of Gravity is
If you implement this equation as your planet's gravity equation your object will mostly fly away from field.
Instead of using this equation you can simply accelerate the object towards center of planet by a constant value.
In Unity it is implemented as rigidbody.addforce(ObjToCentervector,Forcemode.acceleration)
This implementation gave rise to another problem. Acceleration increases velocity exponentially which will make the game very difficult to control.
So instead of using Forcemode.acceleration use Forcemode.VelocityChange which makes your game more controllable. Besides you can change the Drag of the rigidbody to have even more control. I used a value of 0.1 for drag which made the tank go upto the edge of field before orbitting. Increase the drag value if youu want the object to orbit earlier. This will however make the object lose velocity soon and spiral into the planet early.
Hope this article helped you.. Try my game https://play.google.com/store/apps/details?id=com.jaykalabs.atank1free
Read more about:
Featured BlogsYou May Also Like