All Classes Files Functions Variables Enumerations
Public Member Functions | Public Attributes | List of all members
WorldObject Class Reference

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

Detailed Description

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.

Member Function Documentation

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. ::

Parameters
Worldw The world exerting gravity on this WorldObject
See Also
DistanceGravity()
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. ::

Parameters
Worldw The world exerting force on this WorldObject
WorldPhysicsSystemsystem The WorldPhysicsSystem in which the world exists.
See Also
ConstantGravity
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.

Parameters
wThe world being checked with
systemThe WorldPhysicsSystem to calculate with
Returns
This returns the calculated effect of gravity that World w exerts on this WorldObject.
See Also
World.effectiveGravity
WorldPhysicsSystem.GravityMode
bool WorldObject.GetGravityActive ( )

Returns whether or not gravity will affect this WorldObject

Returns
If true, gravity will affect this. Otherwise it will be unaffected
See Also
gravityActive
SetGravityActive
void WorldObject.SetGravityActive ( bool  b)

Sets if gravity will be active on this WorldObject

Parameters
bIf true, gravity will act on this world object. False otherwise.
See Also
gravityActive
GetGravityActive
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

Parameters
Worldw The world that will be orbited
WorldPhysicsSystemsystem The WorldPhysicsSystem the World is part of
See Also
orbitalTarget

Member Data Documentation

bool WorldObject.gravityActive = true

Indicates if gravity will be active on this WorldObject.

See Also
GetGravityActive
SetGravityActive
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

See Also
orbitalTarget
SetOrbital
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.

See Also
SetOrbital
orbitalAxis

The documentation for this class was generated from the following file: