BCE0019: 'point' is not a member of 'Object'. works fine in desktop mode. not for iOS not sure what do to fix. Code (JavaScript): /* Generates a trail that is always facing upwards using the scriptable mesh interface. vertex colors and uv's are generated similar to the builtin Trail Renderer. To use it 1. create an empty game object 2. attach this script and a MeshRenderer 3. Then assign a particle material to the mesh renderer */ var dirChange = false; var height = 2.0; var brushSize = 1.5f; public var time = 2.0; var alwaysUp = false; var minDistance = 0.1; var startColor = Color.white; var endColor = Color (1, 1, 1, 0); var strokeLength = 10f; var terminate = false; class TronTrailSection { var point : Vector3; var upDir : Vector3; var time : float; } private var sections = new Array(); var lastPosition : Vector3; var myDirection : Vector3; function LateUpdate () { transform.Rotate(0, 0, Time.deltaTime * 200); var position = transform.position; position.y -= height/2; var now = Time.time; // Remove old sections //while (sections.length > 0 && now > sections[sections.length - 1].time + time) //{ // sections.Pop(); //} // Add a new trail section if (sections.length == 0 || (sections[0].point - position).sqrMagnitude > minDistance * minDistance) { var section = TronTrailSection (); section.point = position; if (alwaysUp) { if(!dirChange) section.upDir = transform.up ; if(dirChange) section.upDir = transform.right; } else section.upDir = transform.TransformDirection(Vector3.up); section.time = now; sections.Unshift(section); if(height < brushSize) height += 0.05f * brushSize; } // Rebuild the mesh var mesh : Mesh = GetComponent(MeshFilter).mesh; mesh.Clear(); // We need at least 2 sections to create the line if (sections.length < 2) return; var vertices = new Vector3[sections.length * 2]; var colors = new Color[sections.length * 2]; var uv = new Vector2[sections.length * 2]; var previousSection : TronTrailSection = sections[0]; var currentSection : TronTrailSection = sections[0]; // Use matrix instead of transform.TransformPoint for performance reasons var localSpaceTransform = transform.worldToLocalMatrix; // Generate vertex, uv and colors for (var i=0;i<sections.length;i++) { previousSection = currentSection; currentSection = sections[i]; var ratio = i * 1f / sections.length; // Calculate upwards direction var upDir = currentSection.upDir; // Generate vertices vertices[i * 2 + 0] = localSpaceTransform.MultiplyPoint(currentSection.point - upDir * height); vertices[i * 2 + 1] = localSpaceTransform.MultiplyPoint(currentSection.point + upDir * height); //vertices[i] = localSpaceTransform.MultiplyPoint(currentSection.point + upDir * height); //var curDistance = 0.00; uv[i * 2 + 0] = new Vector2(ratio , 0); uv[i * 2 + 1] = new Vector2(ratio, 1); // fade colors out over time //var interpolatedColor = Color.Lerp(startColor, endColor, u); colors[i * 2 + 0] = startColor; colors[i * 2 + 1] = endColor; } if(terminate && sections.length > strokeLength) { Destroy(this); } // Generate triangles indices var triangles = new int[(sections.length - 1) * 2 * 3]; for (i=0;i<triangles.length / 6;i++) { triangles[i * 6 + 0] = i * 2; triangles[i * 6 + 1] = i * 2 + 1; triangles[i * 6 + 2] = i * 2 + 2; triangles[i * 6 + 3] = i * 2 + 2; triangles[i * 6 + 4] = i * 2 + 1; triangles[i * 6 + 5] = i * 2 + 3; } // Assign to mesh mesh.vertices = vertices; mesh.colors = colors; mesh.uv = uv; mesh.triangles = triangles; } @script RequireComponent (MeshFilter)
Thanks. i tried this but now there are many more errors. Code (JavaScript): #pragma strict import System.Collections.Generic; //private var sections = new Array(); var sections = new List.<Vector3>();
i fixed most of the errors. I am stuck on how to fix these as i am not sure how the class TronTrailSection is being applied BCE0019: 'point' is not a member of 'UnityEngine.Vector3'. BCE0022: Cannot convert 'UnityEngine.Vector3' to 'TronTrailSection'. I am also not sure if the list should be a Vector3?