This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start() | |
{ | |
path = FIND<PathCreator>().path; | |
points = path.CalculateEvenlySpacedPoints(spacing); | |
//this spacing is different from the mesh spacing so the mesh stays optimized | |
} | |
Update() | |
{ | |
progress += deltaTime * movementSpeed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get evenly spaced points | |
//points[X] is equal to all the anchorPoints and Handles | |
//starting at the very first anchor then the two handles then the last anchor and so forth | |
public xyz[] CalculateEvenlySpacedPoints(float spacing, float resolution = 1) | |
{ | |
List<xyz> evenlySpacedPoints = new List<xyz>(); | |
evenlySpacedPoints.Add(points[0]); | |
xyz previousPoints = points[0]; | |
float dstSinceLastEvenPoint = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float t; xyz p0; | |
xyz anchor0; xyz p1; | |
xyz anchor1; xyz p2; | |
xyz handle0; xyz p3; | |
xyz handle1; xyz p4; | |
xyz r; | |
private void Update() | |
{ | |
p0 = xyz.Lerp(anchor0, handle0, t); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float Lerp(float val1, float val2, float t) | |
{ | |
return (1 - t) * val1 + t * val2; | |
} | |
xyz Lerp(xyz pos1, xyz pos2, float t) | |
{ | |
return x=Lerp(pos1.x,pos2.x,t) | |
y=Lerp(pos1.y, pos2.y,t) | |
z=Lerp(pos1.z, pos2.z,t) |