- Home /
Question by
Alpacatron · Oct 29, 2016 at 03:52 PM ·
2d gametrailrendererline renderer
How to plot a 2d dotted line
I am trying to plot a 2d dotted line in a ball trajectory, but i can't made this with trail renderer or line renderer, so i need some example code on vectrosity, this is the code that i have so far:
import Vectrosity;
import System.Collections.Generic;
// var lineMaterial : Material;
var maxPoints = 500;
var ballPrefab : Rigidbody;
var force = 16.0f;
private var pathLine : VectorLine;
private var pathIndex = 0;
//private var pathPoints : Vector3[];
var pathPoints = new Vector3[maxPoints];
public var lineTex : Texture;
function Start () {
// pathPoints = new Vector3[maxPoints];
pathLine = new VectorLine("Path", new List.<Vector3>(pathPoints),lineTex, 12.0f, LineType.Continuous);
var ball = Instantiate(ballPrefab, Vector3.zero, Quaternion.Euler(300.0f, 70.0f, 310.0f)) as Rigidbody;
ball.useGravity = true;
ball.AddForce (ball.transform.forward * force, ForceMode.Impulse);
SamplePoints (ball.transform);
Camera.main.transform.position = ball.transform.position;
}
function SamplePoints (thisTransform : Transform) {
var running = true;
while (running) {
pathPoints[pathIndex] = thisTransform.position;
if (++pathIndex == maxPoints) {
running = false;
}
yield WaitForSeconds(.05f);
//pathLine.maxDrawIndex = pathIndex-1;
pathLine.Draw();
pathLine.textureScale = 1.0;
}
}
I took this from a old post, here:
http://answers.unity3d.com/questions/133315/how-to-plot-projectile-path-with-dotted-line.html
But the code is too old and with deprecated commands, when i put in it prints in the console window this message: maxDrawIndex is not a member of vectrosityLine.
Someone have another way to do this?
Comment