Files
ProjectBall.Unity/Assets/Scripts/Controllers/DiaphragmOpenButtonController.cs
T

27 lines
620 B
C#
Raw Normal View History

2025-05-13 05:18:03 +03:00
using UnityEngine;
using System.Collections;
public class DiaphragmOpenButtonController : MonoBehaviour {
public Button1 openPredicate;
private float gateDirection = 1.0f;
public float gateSpeed = 1.0f;
private float gateState = 1.0f;
public Diaphragm target;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (openPredicate != null) {
gateDirection = openPredicate.State() ? -1.0f : 1.0f;
}
gateState = Mathf.Clamp01 (gateState + Time.deltaTime * gateSpeed * gateDirection);
if (target != null) {
target.State = gateState;
}
}
}