// Update is called once per frame void LateUpdate() { if (GameManager.gameIsOver) { return; } TileRail tile = TileMap.Instance.GetTile(railWalker.currentCoords); Vector3 targetPosition = tile.GetPoint(railWalker.EffectiveProgress); targetPosition.y = transform.position.y; transform.position = targetPosition; Vector3 lookAtPosition; if (railWalker.goingReverse) { lookAtPosition = targetPosition - tile.GetDirection(railWalker.EffectiveProgress); } else { lookAtPosition = targetPosition + tile.GetDirection(railWalker.EffectiveProgress); } lookAtPosition.y = transform.position.y;; transform.LookAt(lookAtPosition); }
private void Draw() { //Direction Handles.color = new Color(0, 1, 0, 0.2f); for (int i = 0; i <= SAMPLES; i++) { Vector3 point = rail.GetPoint((float)i / SAMPLES); Vector3 dir = (rail.GetDirection((float)i / SAMPLES)); Handles.DrawLine(point, dir * 0.2f + point); } //Spline Handles.color = Color.blue; for (int i = 0; i <= SAMPLES - 1; i++) { Handles.DrawLine(rail.GetPoint((float)i / SAMPLES), rail.GetPoint((float)(i + 1) / SAMPLES)); } }