Skip to content

Commit 2a29516

Browse files
committed
Fixed action update bug
1 parent f948c97 commit 2a29516

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

Assets/Plugins/UnityActions/Scripts/Actions/ActionInterval.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,45 @@ public class ActionInterval : FiniteTimeAction
2323
{
2424
float completedTime;
2525
bool isFirstTick;
26-
26+
2727
public ActionInterval(float duration)
2828
{
29-
this.duration =duration;
29+
completedTime = 0;
30+
this.duration = duration;
31+
isFirstTick = true;
32+
if (duration == 0)
33+
{
34+
this.duration = epsilon;
35+
}else
36+
{
37+
this.duration = duration;
38+
}
39+
40+
41+
}
42+
43+
public override bool IsDone()
44+
{
45+
return (completedTime >= duration);
3046
}
47+
48+
public override void Update(float delta)
49+
{
50+
if(isFirstTick)
51+
{
52+
isFirstTick = false;
53+
completedTime = 0;
54+
}
55+
else
56+
{
57+
completedTime += delta;
58+
}
59+
60+
LerpAction(Mathf.Max(0,Mathf.Min(1,completedTime / Mathf.Max(duration, epsilon))));
61+
}
62+
63+
64+
3165
}
3266

3367

0 commit comments

Comments
 (0)