浏览代码

Added small internal cooldown to the PlayLandParticlesAction StateAction (#260)

* Added small internal cooldown to PlayLandParticlesAction StateAction

https://open.codecks.io/unity-open-project-1/decks/15-code/card/18k-avoid-spamming-particles-on-sliding

Whenever the PlayLandParticlesAction StateAction is exited by the state machine, it checks if total elapsed time is greater then the total elapsed time of the last particle call + a small amount.

If so, only then do we tell the DustParticle Controller to play, and we also set the new time to beat to be the current time.

* Update PlayLandParticlesActionSO.cs

Removed the unnecessarily verbose extra function

Co-authored-by: Ciro Continisio <ciro@unity3d.com>
/main
GitHub 4 年前
当前提交
5fd25192
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/PlayLandParticlesActionSO.cs

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/PlayLandParticlesActionSO.cs


//Component references
private DustParticlesController _dustController;
private float _coolDown = 0.3f;
private float t = 0f;
public override void Awake(StateMachine stateMachine)
{
_dustController = stateMachine.GetComponent<DustParticlesController>();

{
_dustController.PlayLandParticles();
if (Time.time >= t + _coolDown)
{
_dustController.PlayLandParticles();
t = Time.time;
}
public override void OnUpdate() { }
}
正在加载...
取消
保存