Hey there,
I am making a strategy game for android and I need to guide the player with my finger, drawing a way (way = lineRendererPoints).
When I am done with drawing, the player should follow this way (actually it tracks the points of a lineRenderer), but I don’t know how to solve this. The drawing function is already done.
This Script is for the player, but the player is getting immediately at a random position when drawing is done.
var speed : float = 1f;
var points = new Array();
private var drawLiner : DrawLine;
private var mousePressed : int = -1;
var i : int;
function Start(){
drawLiner = GameObject.Find("DrawLine").GetComponent.<DrawLine>();
}
function Update(){
if(drawLiner.isMousePressed){
mousePressed = 1;
}
if(!drawLiner.isMousePressed && mousePressed == 1){
mousePressed = 0;
}
if(mousePressed == 0){
GetPoints();
mousePressed = -1;
}
while(i < points.length){
transform.position = Vector3.MoveTowards(transform.position, points_, speed * Time.deltaTime);_
-
i++;*
- }*
}
function GetPoints(){ - for(var p : int; p < drawLiner.pointsList.Count; p++){*
-
points[p] = drawLiner.pointsList[p];*
- }*
}