public Vector3 CubicBezier(float t) { const float ArbitraryScale = 1f; return(Bezier.CubicBezier(_p0.position * ArbitraryScale, _p1.position * ArbitraryScale, _p2.position * ArbitraryScale, _p3.position * ArbitraryScale, t)); }
private void CreateTrajectory(float newSpeed, Spawner p1, Spawner p2) { progress = 0; speed = newSpeed; currentTrajectory = Bezier.CubicBezier( p1.origin, p1.forward, p2.backward, p2.origin); }
public void DrawGizmo() { Bezier bezier = Bezier.CubicBezier(p1.origin, p1.forward, p2.backward, p2.origin); float delta = 1 / RESOLUTION; for (var i = 0; i < RESOLUTION; i++) { Gizmos.color = Color.Lerp(p1.color, p2.color, i * delta); Gizmos.DrawLine(bezier.Calculate(i * delta), bezier.Calculate((i + 1) * delta)); } }