Hi everbody.
I am writing curve (ellipse) path modifier. I give radius (distance) from and to position. I use cos and sin but work for a direction, upside to bottom. I need that all form coordinates to all to coordinates working code. e.g 0,2,0 to 0,0,0 and -2,-5,0 to 3,-7,0.
public static void GOPath(Vector3 _from, Vector3 _to, float _duration, float _degree)
{
from = _from;
to = _to;
duration = _duration;
degree = _degree;
disx = to.x - from.x;
disy = to.y - from.y;
radius = 2;
active = true;
}
void Update () {
if (active)
{
elapsedTime += Time.deltaTime;
if (elapsedTime <= duration)
{
//from.x += disx * Time.deltaTime / duration;
from.y += disy * Time.deltaTime / duration;
if (elapsedTime <= duration / 2)
{
from.x += degree * Time.deltaTime / duration;
}
else
{
from.x -= degree * Time.deltaTime / duration;
}
newpos = new Vector3(from.x, from.y, 0);
MyEvent(newpos);
}
else
{
MyEvent(new Vector3(to.x, to.y, 0));
active = false;
}
}
}