【发布时间】:2018-07-27 14:26:25
【问题描述】:
如何在 2 秒后将光强度值从 3.08 更改回 1.0。我在我的代码中有评论以获取更多信息
public class Point_LightG : MonoBehaviour {
public Light point_light;
float timer;
// Use this for initialization
void Start () {
point_light = GetComponent<Light>();
}
// Update is called once per frame
void Update () {
timer -= Time.deltaTime;
lights();
}
public void lights()
{
if (timer <= 0)
{
point_light.intensity = Mathf.Lerp(1.0f, 3.08f, Time.time);
timer = 2f;
}
// so after my light intensity reach 3.08 I need it to gradually change back to 1.0 after 2 seconds.
}
}
【问题讨论】:
-
基本上,您希望在 2 秒内将其从 3.08 更改为 1.0,然后再返回 3.08。来回走动?
-
是的先生来回。