void Update() { Vector3 here = _carController.Position(); if ((here - lastPoint).magnitude > 2) { if (first) { lineRenderer.SetPosition(0, here); lineRenderer.SetPosition(1, here); first = false; Debug.Log(string.Format("Adding the following point to our path trace: {0}", here)); } else { wpt = CommandServer.wpt; lineRenderer.SetVertexCount(lineRenderer.positionCount + 1); lineRenderer.SetPosition(lineRenderer.positionCount - 1, here); lastPoint = here; Debug.Log(string.Format("Adding the following point to our path trace: {0}", here)); Debug.Log(string.Format("My code can tell we are between waypoints {0} and {1}", wpt.prev_wp, wpt.next_wp)); if (wpt.next_wp == 0) { lineRenderer.SetVertexCount(2); first = true; } } } }
// Use this for initialization void Start() { _socket = GameObject.Find("SocketIO").GetComponent <SocketIOComponent>(); _socket.On("open", OnOpen); _socket.On("steer", OnSteer); _socket.On("manual", onManual); _carController = CarRemoteControl.GetComponent <CarController>(); point_path = CarRemoteControl.GetComponent <MyPointTracker>(); wpt = new MyWaypointTracker_mpc(); polyOrder = 5; //Data recording stuff }