Работаю над системой ржавчины
This commit is contained in:
1 parent
3e13180e34
commit
9a52384dbb
19 files changed
+924
-33
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CarRestorationTool : MonoBehaviour
|
||||
{
|
||||
[Header("Параметры")]
|
||||
[SerializeField] private float cleanSpeed = 0.25f; // Сколько ржавчины снимается в секунду
|
||||
[SerializeField] private float range = 2.5f;
|
||||
[SerializeField] private LayerMask interactableLayer;
|
||||
|
||||
private Camera playerCamera;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
playerCamera = Camera.main;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Зажата ЛКМ — процесс чистки
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
TryCleanPart();
|
||||
}
|
||||
}
|
||||
|
||||
private void TryCleanPart()
|
||||
{
|
||||
Ray ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward);
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, range, interactableLayer))
|
||||
{
|
||||
CarPartVisuals visuals = hit.collider.GetComponentInParent<CarPartVisuals>();
|
||||
|
||||
if (visuals != null && visuals.CurrentRust > 0f)
|
||||
{
|
||||
float newRust = visuals.CurrentRust - (cleanSpeed * Time.deltaTime);
|
||||
visuals.SetRust(newRust);
|
||||
|
||||
// Здесь можно запустить систему частиц искр (Particles) и звук шлифмашинки
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user