Moving dotted guide line
I have searched and searched on this forum and youtube but haven't been able to find exactly what I'm looking for (or more likely I don't know how to apply the solution).
I'm looking to make a guide line with dots that travel from GameObject A to wherever target object B is. I think I'm having difficulty in understanding conceptually how to do this.
SEE YOUTUBE LINK BELOW FOR VIDEO OF WHAT IM LOOKING FOR https://www.youtube.com/watch?v=XCM_QwoFsfg
-The color dotted line that shows up when aiming a bubble is what im looking for.
Currently my parent (shooter object) spawns the line of dots and then the parent will rotate to follow (on mouse down)
IEnumerator SpawnDots () {
dotA = Instantiate (AimingBubblePrefab) as GameObject;
dotA.name = "MyDotA";
dotA.SetActive (true);
yield return new WaitForSeconds(aimBubbleLineSpeed);
}
void InstantiateDots () {
dots = new List<Vector2> ();
dotsPool = new List<GameObject> ();
var i = 0;
var alpha = 1.0f / maxDots;
var startAlpha = 1.0f;
while (i < maxDots) {
var dot = Instantiate (dotPrefab) as GameObject;
var sp = dot.GetComponent<SpriteRenderer> ();
var c = sp.color;
dot.transform.SetParent(this.transform);
c.a = startAlpha - alpha;
startAlpha -= alpha;
sp.color = c;
dot.SetActive (false);
dotsPool.Add (dot);
dot.transform.position = new Vector2 (a.x, a.y + i);
dot.SetActive (true);
i++;
}
}
Comment