Public Member Functions | |
float | EffectiveGravityFrom (World w, WorldPhysicsSystem system) |
void | ConstantGravity (World w) |
void | DistanceGravity (World w, WorldPhysicsSystem system) |
void | SetOrbital (World w, WorldPhysicsSystem system) |
bool | GetGravityActive () |
void | SetGravityActive (bool b) |
Public Attributes | |
bool | gravityActive = true |
bool | gravityIgnoresMass = true |
World | orbitalTarget = null |
Vector3 | orbitalAxis = Vector3.up |
This class represents an object under point gravity
This class is the recipient of gravitational influences in the WorldPhysicsSystem. It must have a rigidbody attached, as the WorldPhysicsSystem uses forces to enact point gravity. It shouldn't interfere with any other scripts, as this is simply applying additional forces on the rigidbody. The useGravity variable will be disabled by default, as downwards gravity interferes with point gravity.
To add this to a world physics system, you may do one of two methods. First, you can manually add it to the WorldPhysicsSystem via the inspector. Alternatively, call the WorldPhysicsSystem.AddWorldObject(...) method. In either case, there is no management required by the general programmer.
void WorldObject.ConstantGravity | ( | World | w | ) |
This exerts constant gravity on the WorldObject from some World.
Specifically, the gravity is applied with no reduction over distance. This is logically identical to a WorldGravitySystem with a Distance Decay of 0, but it is more effecient to call this method.
:: This is not intended for general use, and is called by the WorldPhysicsSystem during FIxedUpdate(). If you do call this method, the results will be unpredictable. ::
World | w The world exerting gravity on this WorldObject |
void WorldObject.DistanceGravity | ( | World | w, |
WorldPhysicsSystem | system | ||
) |
This exerts gravity on the WorldObject based on distance
This calculates and applies the effective gravity of World w on this WorldObject, while taking distance into account.
:: This is not intended for general use, and is called by the WorldPhysicsSystem during FixedUpdate(). If you do call this method, the results will be unpredictable. ::
World | w The world exerting force on this WorldObject |
WorldPhysicsSystem | system The WorldPhysicsSystem in which the world exists. |
float WorldObject.EffectiveGravityFrom | ( | World | w, |
WorldPhysicsSystem | system | ||
) |
This calculates the effect of gravity after factors of distance, world gravity strength, and the gravity decay rate of the system in general.
This is not intended for general use, but if you find a reason to use it go ahead.
w | The world being checked with |
system | The WorldPhysicsSystem to calculate with |
bool WorldObject.GetGravityActive | ( | ) |
Returns whether or not gravity will affect this WorldObject
void WorldObject.SetGravityActive | ( | bool | b | ) |
Sets if gravity will be active on this WorldObject
b | If true, gravity will act on this world object. False otherwise. |
void WorldObject.SetOrbital | ( | World | w, |
WorldPhysicsSystem | system | ||
) |
This sets the velocity of the WorldObject such that it will orbit a World
This manually sets the velocity vector of the WorldObject rigidbody to orbit a World. As it does not rely on forces, calling this effectively removes all other forces for one gameplay tick.
This is not intended to be called manually, as it is called during intialization before general forces begin to act on the WorldObject. There will probably not be large problems if it is called manually, but that is beyond the intended scope.
The object will attempt to orbit around the value stored in orbitalAxis
World | w The world that will be orbited |
WorldPhysicsSystem | system The WorldPhysicsSystem the World is part of |
bool WorldObject.gravityActive = true |
Indicates if gravity will be active on this WorldObject.
bool WorldObject.gravityIgnoresMass = true |
Indicates if gravity should ignore mass of the WorldObject
This variable represents the idea that the Worlds are much more massive than the WorldObjects, and that the mass of the WorldObject is essentially negligable.
If this is true, gravity is not modified by mass. If this is false, the forces exerted by gravity are affected by mass.
Vector3 WorldObject.orbitalAxis = Vector3.up |
The axis to orbit around
This is the axis around which the WorldObject will orbit. The default value alligns with the Y axis
World WorldObject.orbitalTarget = null |
This indicates if the WorldObject should initially orbit some World
If you are using realistic gravity mode, it is possible to put a WorldObject into orbit around a World. In situations where there is more than one World in the WorldPhysicsSystem, or the gravity mode is not set to realistic, this will not work reliably.
If null, do not orbit. Otherwise, attempt to orbit the World.