- Home /
Question by
benfattino · Oct 01, 2014 at 11:15 AM ·
lineanimatevectrosity
Animate line vectrosity
I need to animate simple line made with this script:
var Thickness : float;
var lineMaterial : Material;
var StartPoint : Vector3;
var EndPoint : Vector3;
function Start () {
var cubePoints = [StartPoint, EndPoint];
var line = new VectorLine("Cube", cubePoints, lineMaterial, Thickness);
line.textureScale = 1.0;
line.Draw3DAuto();
VectorManager.useDraw3D = true;
VectorManager.ObjectSetup (gameObject, line, Visibility.Dynamic, Brightness.None, false);
}
Is it possible to animate the line by changing the position of the EndPoint?
Comment
I try to destroy and create a new line with this:
import Vectrosity;
var Thickness : float;
var line$$anonymous$$aterial : $$anonymous$$aterial;
var StartPoint : Vector3;
var EndPoint : Vector3;
var OldEndPoint : Vector3;
var LastPoint : Vector3;
var line : VectorLine;
var OBJ : GameObject;
function Start () {
OldEndPoint = EndPoint;
LastPoint = EndPoint;
var cubePoints = [StartPoint, EndPoint];
line = VectorLine("linea", cubePoints, line$$anonymous$$aterial, Thickness);
line.textureScale = 1.0;
line.Draw3DAuto();
Vector$$anonymous$$anager.useDraw3D = true;
Vector$$anonymous$$anager.ObjectSetup (OBJ, line, Visibility.Dynamic, Brightness.None, false);
}
function Update () {
OldEndPoint = LastPoint;
LastPoint = EndPoint;
if (EndPoint != OldEndPoint){
VectorLine.Destroy (line);
var cubePoints = [StartPoint, EndPoint];
line = VectorLine("linea", cubePoints, line$$anonymous$$aterial, Thickness);
line.textureScale = 1.0;
line.Draw3DAuto();
Vector$$anonymous$$anager.useDraw3D = true;
Vector$$anonymous$$anager.ObjectSetup (OBJ, line, Visibility.Dynamic, Brightness.None, false);
}
}
The problem is that the script is attached to an object and must rotate with its. When i use this give me error:
VectorLine "linea" seems to have been destroyed. If you have used ObjectSetup, the way to remove the VectorLine is to destroy the GameObject passed into ObjectSetup.
Object setup need me to make line follow parent object. Somebody can help me? thanks.
Best Answer
Answer by benfattino · Oct 02, 2014 at 11:04 AM
Solved. Hope help someone else.
import Vectrosity;
var Thickness : float;
var lineMaterial : Material;
var StartPoint : Vector3;
var EndPoint : Vector3;
var OldEndPoint : Vector3;
var LastPoint : Vector3;
var line : VectorLine;
var OBJ : GameObject;
var cubePoints : Vector3[];
function Start () {
OldEndPoint = EndPoint;
LastPoint = EndPoint;
cubePoints = [StartPoint, EndPoint];
line = VectorLine("linea", cubePoints, lineMaterial, Thickness);
line.textureScale = 1.0;
line.drawTransform = OBJ.transform;
line.Draw();
}
function Update () {
OldEndPoint = LastPoint;
LastPoint = EndPoint;
if (EndPoint != OldEndPoint){
VectorLine.Destroy (line);
cubePoints = [StartPoint, EndPoint];
line = VectorLine("linea", cubePoints, lineMaterial, Thickness);
line.textureScale = 1.0;
}
line.drawTransform = OBJ.transform;
line.Draw();
}