Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private var beingDragged : Draggable;
- var speed : float = 0.5;
- ////create path with linrenderer
- var lineWidth = 0.02;
- var lineMaterial : Material;
- private var line : LineRenderer;
- function Start()
- {
- lineObject = new GameObject("Line");
- line = lineObject.AddComponent(LineRenderer);
- line.SetWidth(lineWidth,lineWidth);
- line.material = lineMaterial;
- line.SetVertexCount(0);
- }
- function Move(trail : Array) {
- while (trail.Length > 1)
- {
- thisPoint = trail[0];
- nextPoint = trail[1];
- dist = (thisPoint-nextPoint).magnitude;
- lerpDist = 0.0;
- while (lerpDist < dist) {
- i = lerpDist / dist;
- transform.position = Vector3.Lerp(thisPoint, nextPoint, i);
- transform.LookAt(nextPoint);
- yield;
- lerpDist += Time.deltaTime * speed;
- }
- trail.Shift();
- UpdateLine();
- }
- }
- function UpdateLine()
- {
- ///update line vector count
- line.SetVertexCount(activeTrail.length);
- var i = 0;
- for (var drawLine : Vector3 in activeTrail)
- {
- //Debug.Log(drawLine);
- ///loop over the array and appply the line
- line.SetPosition(i, drawLine);
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment