Here’s my code till now
public SpriteShapeController shape;
public int distBtwPoints = 7;
int i = 50;
int x = 1;
public int height=5;
private void Start() {
shape = GetComponent<SpriteShapeController>();
for (int i =0; i<50; i++){
shape.spline.SetPosition(i+2,shape.spline.GetPosition(i+2) + Vector3.right*distBtwPoints + Vector3.down*1);
shape.spline.SetPosition(i+3,shape.spline.GetPosition(i+3) + Vector3.right*distBtwPoints + Vector3.down*1);
float xPos = shape.spline.GetPosition(i+1).x + distBtwPoints;
shape.spline.InsertPointAt(i + 2, new Vector3(xPos,height*Mathf.PerlinNoise(i*Random.Range(5f,15f),0) - i));
shape.spline.SetTangentMode(i+2,ShapeTangentMode.Continuous);
shape.spline.SetLeftTangent(i+2, new Vector3(-4,0,0));
shape.spline.SetRightTangent(i+2, new Vector3(4,0,0));
}
InvokeRepeating("Generate",5,0.3f);
}
private void Generate() {
shape.spline.RemovePointAt(1);
shape.spline.SetPosition(0,shape.spline.GetPosition(1)+Vector3.down*100);
shape.spline.SetPosition(i+2-x,shape.spline.GetPosition(i+2-x) + Vector3.right*distBtwPoints + Vector3.down*1);
shape.spline.SetPosition(i+3-x,shape.spline.GetPosition(i+3-x) + Vector3.right*distBtwPoints + Vector3.down*1);
float xPos = shape.spline.GetPosition(i+1-x).x + distBtwPoints;
shape.spline.InsertPointAt(i + 2-x, new Vector3(xPos,height*Mathf.PerlinNoise((i-x)*Random.Range(5f,15f),0) - (i)));
shape.spline.SetTangentMode(i+2-x,ShapeTangentMode.Continuous);
shape.spline.SetLeftTangent(i+2-x, new Vector3(-4,0,0));
shape.spline.SetRightTangent(i+2-x, new Vector3(4,0,0));
i++;
x++;
}
I’ve generated a big mesh having 50 nodes in the start method and then in the generate method im simultaneosly deleting and adding 1 node at a time so that the mesh doesnt’t take up too much space.
Now here’s the issue. Im using invokerepeating to call the method so my entire code depends on whether the speed of the snowboarder and the speed of the node deletion is same. If not, one of them would get too ahead of the other and eventually the snowboarder will have nothing below him.
Here’s what i wanna do. I want to create a trigger parented to the snowboarder and when a node touches the trigger it gets deleted. Any idea on how to do it?