Calculate distance between player and empty objects trail renderer

I have an empty object with a trail renderer attached, which has been animated to follow a certain path on the terrain. The animation plays once upon start up and ends at its starting position. This all works nicely, however I would now like to detect the distance from the player object to the nearest verticy of the trail renderer component. Before I used the following code to calculate the distance between two objects:

function Update () 
  dist = Vector3.Distance(Object1.transform.position, Object2.transform.position);

This code will only find the distance between two objects and since the trail renderer isn’t an object itself - rather a component of an object, this code won’t work properly.
What I am asking is how to find the distance between a verticy of the trail renderer and the player object.
I’m not sure if there is a way to access the component through a normal script, but if anyone has any ideas I’d appreciate the help :slight_smile:

Or alternatively - Is there a way to add a trigger to the trail renderer?

There is no way to access the individual points of a trail renderer. There really should be. (Also, if you were wondering how to change the colors in a trail renderer from a script, same answer- you can’t.)
What you could do is create a List.{Vector3} and have the object with the trail add its current location to the list every so often and start removing the oldest points from it so it is only as long as the trail- then for…in loop through each position in the list and compare it to the player object. If it’s shorter than the previous shortest distance, set the shortest distance to that. Then when the loop’s done, if the overall shortest distance is less than however close it needs to be; then set the player on fire or whatever.

This could be a slow script so just make sure you don’t make it more fine-grained than it really needs to be. You could probably just make it a list of Vector2s and use SqrMagnitude, and that would be cheaper.

(Also; it’s vertex.)