File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed
Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 11version https://git-lfs.github.com/spec/v1
2- oid sha256:07e9ae6fb1aa5e25d781758d64a3251b14ab3aa03941e1027ecda8c43ac2fa29
3- size 259
2+ oid sha256:b51e663d2808d0ee41901a13877bbe2968e4ef20151bedb4c350b95da82172bb
3+ size 19645
Original file line number Diff line number Diff line change 44
55public class TrailController : MonoBehaviour {
66
7+ public GameObject avatar ;
78 public TrailRenderer trailRenderer ;
89 public int siblingCount ;
910 public int trailIndex ;
@@ -28,6 +29,7 @@ private void Awake ()
2829 {
2930 // get renderer
3031 trailRenderer = GetComponent < TrailRenderer > ( ) ;
32+ trailRenderer . enabled = false ;
3133 }
3234
3335
@@ -72,6 +74,8 @@ public void Init ()
7274 // set the trail width to the range plus a 'lil extra to cover the background
7375 trailWidth = trailsRange + widthExtra ;
7476
77+ // how long trail lasts, a.k.a. its length
78+ trailRenderer . time = siblingCount ;
7579
7680 // set offset based on index
7781 transform . localPosition = new Vector3 ( 0 , positionsByIndex [ trailIndex ] , 0 ) ;
@@ -84,6 +88,9 @@ public void Init ()
8488 trailRenderer . numCornerVertices = 10 ;
8589 trailRenderer . numCapVertices = 5 ;
8690
91+ //trailRenderer.sortingOrder = avatar.GetComponent<SpriteRenderer> ().sortingOrder;
92+
93+ trailRenderer . enabled = true ;
8794 }
8895
8996
Original file line number Diff line number Diff line change @@ -14,22 +14,38 @@ private void Awake ()
1414 {
1515 trailDict = new Dictionary < string , GameObject > ( ) ;
1616
17- // TEMP ADD RANDOM COUNT
17+ StartCoroutine ( AddTestTrails ( 1f ) ) ;
18+
19+ }
20+
21+
22+
23+ /**
24+ * Adds random number of test trails
25+ */
26+ IEnumerator AddTestTrails ( float wait )
27+ {
28+ yield return new WaitForSeconds ( wait ) ;
29+
30+ // random num
1831 numberTrails = ( int ) Random . Range ( minTrailCount , maxTrailCount ) ;
32+ // add trail
1933 for ( int i = 0 ; i < numberTrails ; i ++ ) {
2034 AddTrail ( i , false ) ;
2135 }
2236 // update after a second
2337 StartCoroutine ( UpdateTrails ( 1f ) ) ;
38+
2439 }
2540
2641
42+
2743 /**
2844 * Adds the trail at index
2945 */
3046 void AddTrail ( int index , bool updateAll )
3147 {
32- // add player to scene
48+ // add trail to scene
3349 GameObject obj = ( GameObject ) Instantiate ( trailPrefab ) ;
3450 // create name for trail obj
3551 string name = "trail-" + ( index + 1 ) . ToString ( ) ;
You can’t perform that action at this time.
0 commit comments