I am trying to make a pen which writes with a trail renderer when the tip of the pen is colliding with the paper. When the pen is not on the paper I want it to stop the trail renderer, but at the same time keep the lines it previously made.
Is there any way possible where I can de-Activate the trail renderer on my object but keep the lines that it previously made?
Well, I mainly only have a solution to 1 part of your question. That is to keep trail. All you need to do basically is make the time variable very very high or put ‘infinity’ there (at least infinity should work…although I haven’t tried it yet). Also if you haven’t done so, might I suggest making the MinVertexDistance very low as well, since that makes the trail smoother.
As for the second issue, you could try something like the following adapted to a trailrenderer.
gameObject.GetComponent(ParticleEmitter).emit= false; //tell the emitter to stop
Ok well, I did not figure out how to do exactly what I Originally asked, but I did a little magic trick instead. I have two objects, The first is a Pen which is above the drawing surface, The second is the Pen tip which is under my drawing surface. When the Pen gets closer to the drawing surface from above, the Pen tip get closer from the back. Eventually the pen tip with the trail renderer becomes visible and it looks as if the pen is drawing. I know that this has some flaws and will not work if your surface is not wide enough to hide the Pen.
This does not deserve to be the correct answer to my problem, but it is more of an alternative solution.
I wanted to disable the renderer when not using an attack so i just changed the width to zero.
Example:
private TrailRenderer tr;
void Start () {
tr = GetComponent();
}
void Update () {
if (Input.GetKey ("w")) {
tr.widthMultiplier = 0.0f;
}
if (Input.GetKey ("1")) {
tr.widthMultiplier = 3.0f;
}
}