Calculating Planet Gravity in Unity3D

Описание к видео Calculating Planet Gravity in Unity3D

This video covers how to create custom gravity beyond the default Unity gravity so that developers may implement a gravity force that can pull towards a planet form any direction. The demonstration uses a buggy with an attached Rigidbody component, simple cube collider, and 4 wheel colliders, and a sphere which we set as our source of gravity in the script.

In addition to calculating gravity, we cover how to rotate our objects so that they orient to be "face up" from the planet even if they aren't on the surface or if the object needs correction. By the end of the tutorial you'll get a car that can drive around a planet, and if it happens to go fast enough to leave the surface can return on its wheels.

Some functions covered are: Quaternion.FromToRotation, which returns a rotation value between two vectors, Quaternion.Slerp, Rigidbody.AddRelativeForce, Rigidbody.AddRelativeTorque, Rigidbody.AddForce, and getting a Rigidbody mass with Rigidbody.mass.

Комментарии

Информация по комментариям в разработке