new action ActionBezierAbs.cs
This commit is contained in:
@@ -41,7 +41,8 @@ Interval actions
|
||||
- [x] FadeBy *if you want to manipulate alpha, your material must support transparency*
|
||||
- [ ] JumpTo
|
||||
- [ ] JumpBy
|
||||
- [ ] Bezier
|
||||
- [x] BezierAbs
|
||||
- [ ] BezierRel
|
||||
- [ ] Blink
|
||||
|
||||
Instant actions
|
||||
|
||||
45
src/ActionsInterval/ActionBezierAbs.cs
Normal file
45
src/ActionsInterval/ActionBezierAbs.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
class ActionBezierAbs : ActionInterval
|
||||
{
|
||||
public Vector3 startPoint;
|
||||
public Vector3 endPoint;
|
||||
public Vector3 startControlPoint;
|
||||
public Vector3 endControlPoint;
|
||||
|
||||
public ActionBezierAbs(Vector3 tgtStart, Vector3 tgtSCP, Vector3 tgtECP, Vector3 tgtEnd, float tgtDuration)
|
||||
: base(tgtDuration)
|
||||
{
|
||||
startPoint = tgtStart;
|
||||
endPoint = tgtEnd;
|
||||
startControlPoint = tgtSCP;
|
||||
endControlPoint = tgtECP;
|
||||
}
|
||||
|
||||
public override Action clone()
|
||||
{
|
||||
return new ActionBezierAbs(startPoint, startControlPoint, endControlPoint, endPoint, duration);
|
||||
}
|
||||
|
||||
public override Action reverse()
|
||||
{
|
||||
return new ActionBezierAbs(endPoint, endControlPoint, startControlPoint, startPoint, duration);
|
||||
}
|
||||
|
||||
public override void start()
|
||||
{
|
||||
base.start();
|
||||
}
|
||||
|
||||
public override void stepInterval(float dt)
|
||||
{
|
||||
float t = timer / duration;
|
||||
Vector3 newPosition = (((-startPoint
|
||||
+ 3 * (startControlPoint - endControlPoint) + endPoint) * t
|
||||
+ (3 * (startPoint + endControlPoint) - 6 * startControlPoint)) * t +
|
||||
3 * (startControlPoint - startPoint)) * t + startPoint;
|
||||
target.gameObject.transform.position = newPosition;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user