This commit is contained in:
Crizomb 2024-12-10 22:32:20 +01:00
parent 3a7ce962e7
commit 058e61a4fd
38 changed files with 3915 additions and 363 deletions

View file

@ -2,8 +2,12 @@ using UnityEngine;
public class Boost : MonoBehaviour
{
[SerializeField] Rigidbody rb;
[SerializeField] float boostMultiplier;
[SerializeField] Rigidbody _rb;
[SerializeField] float boostForce;
[SerializeField] float boostRefillTime;
[HideInInspector]
public float charge { get; private set; } // Beetwen 0 and 1
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
@ -14,10 +18,13 @@ public class Boost : MonoBehaviour
// Update is called once per frame
void Update()
{
// Middle click
if (Input.GetMouseButton(2))
charge = Mathf.Clamp(charge + Time.deltaTime / boostRefillTime, 0, 1.0f);
// Middle click and 0.99f because I'm affraid of floating point comparison
if (Input.GetMouseButton(2) && charge >= 0.99f)
{
rb.linearVelocity *= boostMultiplier;
_rb.AddForce(boostForce * _rb.transform.forward, ForceMode.Impulse);
charge = 0;
}
}
}