SWS-Smarta / project /Assets /Scripts /Game /DinoVFXController.cs
alfapro's picture
Clean deploy: Code only for SWS
defab59
Raw History Blame Contribute Delete
1.06 kB
using UnityEngine;
public class DinoVFXController : MonoBehaviour
{
public DinoPlayer player;
public ParticleSystem dust;
public TrailRenderer speedTrail;
public GameObject speedLines;
public float boostThreshold = 1.1f;
public float dustMinSpeed = 0.1f;
void Awake()
{
if (player == null)
player = GetComponentInParent<DinoPlayer>();
}
void Update()
{
if (player == null || player.ncc == null)
return;
bool grounded = player.ncc.IsGrounded;
bool boosting = player.SpeedMultiplier >= boostThreshold;
bool moving = player.IsAlive;
if (dust != null)
{
if (grounded && moving)
{
if (!dust.isPlaying) dust.Play();
}
else
{
if (dust.isPlaying) dust.Stop();
}
}
if (speedTrail != null)
speedTrail.emitting = boosting;
if (speedLines != null)
speedLines.SetActive(boosting);
}
}