Added skinned mesh collider. Changed Heat Reset from list to event action. Added curve to heat buildup

This commit is contained in:
Thorbjoern
2025-07-20 04:16:55 +02:00
parent aff0db9b64
commit 2dfa84a0e8
330 changed files with 32792 additions and 353 deletions
+39 -5
View File
@@ -1,24 +1,58 @@
using GhostSystem;
using UnityEngine;
public class RecieveHeat : MonoBehaviour
{
private float heatLevel;
public Renderer myRenderer;
private float heatLevel; // von 0-255
private float heatLevelNormalized; // von 0-1
private Material myMat;
private async void OnEnable()
{
GhostReplayManager.OnRestartLoop += HandleRestartLoop;
}
private void OnDisable()
{
GhostReplayManager.OnRestartLoop -= HandleRestartLoop;
}
private void HandleRestartLoop()
{
SetHeat(0);
}
private void Start()
{
myMat = GetComponent<Renderer>().material;
if (myRenderer == null)
{
TryGetComponent<Renderer>(out myRenderer);
}
myMat = myRenderer.material;
SetHeat(0);
}
public void SetHeat(float heat)
{
if (heat > 255) return;
if (heat > 1f) return;
heatLevel = heat;
myMat.color = new Color(heatLevel,0,0);
float redAmount = CalcRedAmount(heatLevel);
myMat.color = new Color(redAmount,0,0);
}
public void AddHeat(float heat)
{
heatLevel += heat;
myMat.color = new Color(heatLevel, 0, 0);
if (heatLevel > 1f) return;
float redAmount = CalcRedAmount(heatLevel);
Debug.Log(gameObject.ToString() + "Heat in: " + heatLevel + "Heat out: " + redAmount);
myMat.color = new Color(redAmount, 0, 0);
}
private float CalcRedAmount(float xNormalized)
{
float y = Mathf.Pow(xNormalized, 0.5f);
return Mathf.Clamp(y, 0f, 1f);
}
}