- Home /
How can I increase the view-distance of a trail renderer?
I've created a game where the player must travel across a galaxy in order to get home. As the player travels he/she leaves behind a trailer renderer which marks the course of the ship's jumps from star to star.
At the moment the trail hits a certain viewing distance and then disappears. I'd really like to have a larger viewing angle for the trail?
Is this possible? If not, I think I may mess around with WorldToScreen and see if I can't do a line renderer, but I thought I'd check.
Thanks!
Below: the trail only goes a certain distance before disappearing. There are 5 or six jumps that can't be seen.
Answer by ArgusSendMore · Sep 09, 2014 at 09:56 PM
Got it. This was a two part solution.
Part 1 is to increase the draw distance for the camera. I went to the Main Camera and changed the far clipping pane to 100,000.
Part 2 was to increase the distance of the trail renderer over type.
TrailRenderer trail; //created a variable to hold the trail
public Vector3 gameStart;
void Start() {
gameStart = transform.position; //marks the place where the player starts.
trail = gameObject.GetComponent<TrailRenderer>(); //sets the variable to refer to the trail renderer on the player
}
void Update () {
TrailChanges ();// every frame I run the method TrailChanges
}
void TrailChanges(){
trail.endWidth = Vector3.Distance (transform.position, gameStart) / 100f + .5f; //as the player recedes from the start point, the end width of the trail becomes thicker, so that it appears to remain the same width at a distance
}
End result is this!