Ejemplo n.º 1
0
        public Trail(Main main)
        {
            this.main = main;
            points = new List<TrailPoint>();
            followers = new List<Transform>();
            noTouchPoints = new List<Transform>();

            //Transform pathStart = (Transform)UnityEngine.Object.Instantiate(main.cubePrefab, player.transform.position, Quaternion.identity);
            TrailPoint pathStart = new TrailPoint
            {
                position = player.transform.position,
                rotation = Quaternion.identity
            };
            points.Add(pathStart);
        }
Ejemplo n.º 2
0
        public void TryGrowPath()
        {
            // TODO: Scale this with Time
            while (true)
            {
                TrailPoint end = points[points.Count - 1];
                if (Vector3.Distance(end.position, player.transform.position) > pointGap)
                {
                    Vector3 newPos = Vector3.MoveTowards(end.position, player.transform.position, pointGap);
                    //Transform newPart = (Transform)UnityEngine.Object.Instantiate(main.cubePrefab, newPos, player.transform.rotation);
                    TrailPoint newPart = new TrailPoint
                    {
                        position = newPos,
                        rotation = player.transform.rotation
                    };
                    points.Add(newPart);

                    if (nextNoTouchPoint < points.Count)
                    {
                        TrailPoint checkPoint = points[nextNoTouchPoint];
                        if (Vector3.Distance(checkPoint.position, player.transform.position) > noTouchPointDist)
                        {
                            Transform noTouchCube = (Transform)UnityEngine.Object.Instantiate(main.noTouchCube, checkPoint.position, checkPoint.rotation);
                            noTouchPoints.Add(noTouchCube);
                            checkPoint.cube = noTouchCube;
                            nextNoTouchPoint += noTouchPointFreq;
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            //Transform end = trail[trail.Count - 1];
            //Transform newPart = (Transform)Instantiate(cubePrefab, end.position, end.rotation);
            //newPart.position += 0.5f * newPart.forward;
            //newPart.Rotate(new Vector3(0, Random.Range(-50, 50), 0));
            //trail.Add(newPart);
        }