WERE FLYING IN DA AIR

This commit is contained in:
2025-03-28 14:53:19 +00:00
parent 01e700a00e
commit 6b565e5abc
3 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using UnityEngine;
public class GravityController
{
// The only instance of the class
static GravityController s_Instance = null;
// Constant gravity scale
const float m_GravityScale = 20.0f;
// Private constructor to stop accidental creation
private GravityController()
{ }
public static GravityController Instance()
{
// Creates an instance if there is not already one
if (s_Instance == null)
{
s_Instance = new GravityController();
}
// Returns the instance
return s_Instance;
}
public void SetScale(float scale)
{
// Sets the gravity
Physics.gravity = new Vector3(0, m_GravityScale * scale, 0);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56c7a2685fd932c4aa322d5b48fbd2aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -79,6 +79,10 @@ public partial class PlayerMovement : MonoBehaviour
if (Mathf.Abs(v.z) < 0.1f) { v.z = 0.0f; } if (Mathf.Abs(v.z) < 0.1f) { v.z = 0.0f; }
m_Body.velocity = v; m_Body.velocity = v;
// Doubles gravity if falling to feel less floaty
if (v.y < 0.0f) { GravityController.Instance().SetScale(2.0f); }
else { GravityController.Instance().SetScale(1.0f); }
// Clears all stored collisions // Clears all stored collisions
m_WallCollisions.Clear(); m_WallCollisions.Clear();
} }