Moving objects leave a trail/ghosting/blur( Need Help)
Hello. I make a game on Unity 5.6.0b1 and there is a problem , where moving objects(3d model and text) leave a trail of color. I didn`t find a solution, but i hope that you will help me. I made a video with this problem.
Answer by doge-man-zain · Aug 24, 2017 at 09:30 AM
I was literally trying to do the exact same thing and came up with this solution
For this to work your material must have a property that you want to effect over time. In my case it was transparency.
public class TrailScript : MonoBehaviour {
public int samples = 3;
Material mat;
Mesh msh;
Queue<Matrix4x4> TRS = new Queue<Matrix4x4>();
MaterialPropertyBlock mpb;
// Use this for initialization
void Start () {
mat = GetComponent<MeshRenderer> ().sharedMaterial;
msh = GetComponent<MeshFilter> ().sharedMesh;
mpb = new MaterialPropertyBlock ();
}
// Update is called once per frame
void Update () {
TRS.Enqueue (Matrix4x4.TRS(transform.position,transform.rotation,transform.localScale));
if (TRS.Count >= samples) {
TRS.Dequeue ();
}
Matrix4x4[] matrix = TRS.ToArray();
for (int i = 0; i < matrix.Length; i++) {
mpb.SetFloat ("_Transparency",(float)i/matrix.Length);
Graphics.DrawMesh (msh,matrix[i],mat,0,null,0,mpb);
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612131316im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
When i clicked on any particular object in my GAME then only the background should get blurred? 0 Answers
Motion blur on moving object - without moving the camera (post-processing stack v2) 0 Answers
How do I make a trail fullbright? 1 Answer
Trail renderer jitter when using positionCount 0 Answers
Shader blurs only one shader 0 Answers