- Home /
Set trail renderer color and gradient in script?
I want the trail behind a projectile to be based on a player's color. 1-4 players will take turns shooting a basketball, with this trail serving as a visual indicator of which player shot the ball. So i need a script to set the color of the trail of an instantiated ball based on a "playercolor" variable. I attempted to implement the solution described here: https://answers.unity.com/questions/1558539/how-do-i-change-the-trail-renderer-color-in-script.html, however, adding a red colored material as the TrailRenderer's second element (the first element 0 is the Default-ParticleSystem) just makes the trail a solid block of awful-looking red. I want the trail to have a gradient, going from red (or whatever given playercolor) to white-translucent. How can I add a material to the TrailRenderer such that the gradient still works the same way (transitioning from playercolor to translucent), but with 4 possible playercolors being set within a c# script?
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Changing material color creates a memory leak 1 Answer
How to change the color of all objects that use the same material? 0 Answers
Why does my code have no effect on the materials color? 1 Answer