0

I have a single mesh game object that is essentially a long line that curves and slopes up/down. What I'm trying to do is generate some text along this line at a specified distance interval. Let's say every 100 units along the line some text should appear. If it was a straight line it would be easy, but the curves and slopes are throwing me off.

I retrieved the vertices that created this mesh by doing:

model.GetComponent<MeshFilter>().mesh.vertices

I then transform them to world-space by looping over them and doing:

meshFilter.gameObject.transform.TransformPoint(vertices[i])

Now, these vertices are NOT evenly spaced. For slopes and curves, there are a lot of vertices. For the straighter parts, there are less. But these straight parts still vary slightly (usually by ~.10 of the Y value). Originally I was looping through and keeping track of the distance to find the vertices closest to the interval, but that was when I thought they were evenly spaced.

Here's part of the model:

enter image description here

I colored all the vertices black here to show how condensed they are at curves/slopes vs ~straight parts:

enter image description here

Here's the inspector for the model just incase:

enter image description here

pfinferno
  • 1,779
  • 3
  • 34
  • 62

1 Answers1

1

Do you use a static single mesh?
In your solution, I think the problem is vertices. you have to find vertices along your line and ignore the vertical group of them and its too difficult.
If your mesh may be changed by player, I suggest you to use Trail Render Component, get its vertices and solve a simple Knapsack problem to put your characters (suggest you use TextmeshPro)

  • If by static you mean the static checkbox in the inspector, no that is not checked. I'll look into the Trail Render Component, thanks! – pfinferno Apr 18 '20 at 18:39