Skip to main content

GravityChanger

A class in Root.Township, the global namespace.

Debug component on a player character: holding the Debug1 action on both hands raises global gravity until it is reversed, then it drops back.

Constructors​

MemberWhat it is
GravityChanger()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private float defaultGravityGravity Y at start.
private float gravityChangeGravity change per frame.
private Coroutine gravityUpCoroutineRunning raise coroutine.
private PlayerCharacter playerCharacterBacking field for PlayerCharacter.

Properties​

MemberWhat it is
PlayerCharacter PlayerCharacter { get; }The player character on this object.

Methods​

4 private and internal methods
MemberWhat it is
private IEnumerator BringGravityDown() (iterator)Coroutine that lowers Physics.gravity back to the default.
private IEnumerator BringGravityUp() (iterator)Coroutine that raises gravity each frame while both Debug1 actions are held, with haptics, then calls BringGravityDown.
private void ChangeGravity(PlayerInput controller)Restarts BringGravityUp when Debug1 starts on either hand.
private void Start()Saves the default gravity and hooks Debug1 on both controllers.