Click or drag to resize

GravitationalSystem Class

A gravitational system to allow for a more flexible gravity instead of just a constant directional gravity. Useful for planets, black holes, magnets etc. Rigidbodies that should be affected should have the GravitationalEntity component (or GravitationalEntity2D if using 2d physics). Add gravitational forces by implementing the IGravitationalAffecter interface and registering it in the system. See SphericalGravitationalPoint for a simple example implementation.
Remarks
You might want to set Unity's gravity to (0,0,0).
Inheritance Hierarchy
SystemObject
  Archon.SwissArmyLib.GravityGravitationalSystem

Namespace:  Archon.SwissArmyLib.Gravity
Assembly:  Archon.SwissArmyLib (in Archon.SwissArmyLib.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class GravitationalSystem : IEventListener
Request Example View Source

The GravitationalSystem type exposes the following members.

Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Destructor
(Overrides ObjectFinalize.)
Public methodStatic memberGetGravityAtPoint
Gets the sum of all gravitational forces at a specific location.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberRegister(Rigidbody)
Registers a Rigidbody that should be affected by gravitational forces in this system.
Public methodStatic memberRegister(Rigidbody2D)
Registers a Rigidbody2D that should be affected by gravitational forces in this system.
Public methodStatic memberRegister(IGravitationalAffecter)
Registers a gravitational affecter to be part of the system.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberUnregister(Rigidbody)
Unregisters a Rigidbody from the system, so it no longer is affected by gravitational forces in this system.
Public methodStatic memberUnregister(Rigidbody2D)
Unregisters a Rigidbody2D from the system, so it no longer is affected by gravitational forces in this system.
Public methodStatic memberUnregister(IGravitationalAffecter)
Unregisters a gravitational affecter from the system, so it no longer affects entities.
Top
See Also