GRAVITY
2020 // A Familiar Face
Inspired by the catastrophe that was Escape The Dark and a newfound acquaintance with the Unity engine, my heart was pulled back to the gravity flipping concept from three years prior.
I expanded from simply flipping vertically to all 3 axis, allowing the player to walk on any surface by reorienting (map is all axis-aligned). The most exciting part was the potential for novel platforming by jumping and changing gravity midair.
Unfortunately this never made it past the block out stage, but at least there was a working implementation of the movement with smooth camera rotation.
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class PlayerMvmt : MonoBehaviour
6 {
7 public CharacterController controller;
8
9 public float speed = 12f;
10 public float gravity = 10f;
11 public float jumpHeight = 3f;
12 public float rotateSpeed;
13 public Transform playerBody, playerParent;
14
15 public Transform groundCheck;
16 public float groundDistance = 0.2f;
17 public LayerMask groundMask;
18
19 Vector3 velocity, movement;
20 bool isGrounded, wait;
21
22 float rotationProgress = -1;
23 float x, y, z;
24
25 Quaternion startRotation, endRotation;
26
27 void Update()
28 {
29 Quaternion? targetRotation = null;
30
31 if (Input.GetKeyDown("g") && !wait)
32 {
33 startRotation = playerBody.localRotation;
34 y = (startRotation.eulerAngles[1] - (startRotation.eulerAngles[1] % 90));
35 targetRotation = Quaternion.Euler(0f, y, 180f);
36 }
37 else if (Input.GetKey("left shift") && Input.GetKeyDown("t") && !wait)
38 {
39 startRotation = playerBody.localRotation;
40 y = startRotation.eulerAngles[1] % 90;
41 if (y >= 45)
42 {
43 y = (startRotation.eulerAngles[1] + (90 - y));
44 }
45 else
46 {
47 y = (startRotation.eulerAngles[1] - (startRotation.eulerAngles[1] % 90));
48 }
49
50 targetRotation = Quaternion.Euler(90f, y, 0f);
51 }
52 else if (Input.GetKeyDown("t") && !wait)
53 {
54 startRotation = playerBody.localRotation;
55 y = startRotation.eulerAngles[1] % 90;
56 if (y >= 45)
57 {
58 y = (startRotation.eulerAngles[1] + (90 - y));
59 }
60 else
61 {
62 y = (startRotation.eulerAngles[1] - (startRotation.eulerAngles[1] % 90));
63 }
64
65 targetRotation = Quaternion.Euler(-90f, y, 0f);
66 }
67 else if (Input.GetKey("left shift") && Input.GetKeyDown("f") && !wait)
68 {
69 startRotation = playerBody.localRotation;
70 y = (startRotation.eulerAngles[1] - (startRotation.eulerAngles[1] % 90));
71 targetRotation = Quaternion.Euler(0f, y, -90f);
72 }
73 else if (Input.GetKeyDown("f") && !wait)
74 {
75 startRotation = playerBody.localRotation;
76 y = (startRotation.eulerAngles[1] - (startRotation.eulerAngles[1] % 90));
77 targetRotation = Quaternion.Euler(0f, y, 90f);
78 }
79
80 if (targetRotation.HasValue)
81 {
82 endRotation = playerParent.rotation * targetRotation.Value;
83 playerBody.localRotation = Quaternion.identity;
84 rotationProgress = 0;
85 }
86
87 if (rotationProgress < 1 && rotationProgress >= 0)
88 {
89 wait = true;
90 rotationProgress += Time.deltaTime * rotateSpeed;
91 playerParent.localRotation = Quaternion.Lerp(startRotation, endRotation, rotationProgress);
92 }
93 else
94 {
95 wait = false;
96 }
97
98 // Jump
99 isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
100
101 if (Input.GetButtonDown("Jump") && isGrounded)
102 {
103 velocity.y = Mathf.Sqrt(jumpHeight * 2f * gravity);
104 }
105
106 if (wait)
107 {
108 velocity.y = 0;
109 }
110 else
111 {
112 velocity.y -= gravity * Time.deltaTime;
113 }
114 movement = transform.TransformDirection((velocity * Time.deltaTime));
115 controller.Move(movement);
116
117 // Movement
118 float x = Input.GetAxis("Horizontal");
119 float z = Input.GetAxis("Vertical");
120
121 Vector3 move = transform.right * x + transform.forward * z;
122 controller.Move(move * speed * Time.deltaTime);
123 }
124 }
125
Making games kind of fell on the backburner for some time, but getting through this project definitely rekindled a spark. I haven't really gone back to this flipping idea yet (as of 2026), but some of its spirit found its way into Unicorn in which you're now flipping in 2D but space is connected to time (a la Braid).