How to Simulate Gravity in Unity
Video Statistics and Information
Channel: Brackeys
Views: 329,328
Rating: undefined out of 5
Keywords: brackeys, unity, unity3d, beginner, easy, how, to, howto, learn, course, tutorial, tutorials, game, development, develop, games, programming, coding, basic, basics, C#, simulation, space, planet, planets, gravity, forces, force, gravitational, Newton, newtons law, simulations, intermediate
Id: Ouu3D_VHx9o
Channel Id: undefined
Length: 9min 23sec (563 seconds)
Published: Sun Aug 06 2017
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Very clear and direct solution to the problem. I have seen comments that this style of approach can result in orbits that are not fully closed in the case of two bodies - which I have assumed is due to issues with the underlying integrator in Unity.
Two observations: (1) if you have a centralized gravity then you can take advantage of the fact that force of A on B is equal and opposite of force of B on A, instead of calculating each (2) Mathf.Pow can be easily avoided by doing distance*distance
(Disclaimer: I'm the author of the Gravity Engine asset)
I normally avoid vid tutorials because people don't bother editing them and it becomes painfully long but wow, learned a ton in just a short span of time. Great job!
Am on a very tiny screen, and honestly thought I was going to learn how to simulate gravy in Unity... ffwd'd quickly to the end, was thoroughly disappointed.