A class in Root.Township, Alta.Networking.
Replaces Unity gravity on a rigidbody with a ConstantForce, so gravity and drag can be changed per object and synced to clients.
Constructors
| Member | What it is |
|---|
NetworkGravity() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
3 private and internal fields
| Member | What it is |
|---|
private Rigidbody cachedRigidbody | The rigidbody whose drag is synced. |
private ConstantForce gravity | The constant force used as gravity. |
private MethodSync syncGravity | Method sync for gravity and drag. |
Properties
| Member | What it is |
|---|
float Drag { get; set; } | The rigidbody's drag. Setting it sends the new values to clients. |
float Gravity { get; set; } | Vertical gravity force. Setting it sends the new values to clients. |
Methods
| Member | What it is |
|---|
override void Initialize() | Creates the gravity method sync. |
override void OnConnected(Player player) | Sends the gravity and drag to a newly connected player. |
void Reset() | Sets gravity back to the normal physics gravity. |
2 private and internal methods
| Member | What it is |
|---|
private bool EditorSetup() | Editor: adds the constant force set to normal gravity and turns off the rigidbody's own gravity. |
private void Sync(IPlayer player, Stream stream) | Sends or receives gravity (-10 to 10) and drag (0 to 5), both in steps of 0.1. |