private void Move() { if (Mathf.Abs(distance - currentSegment.Length) < distanceDiff) { currentSegment = currentSegment.GetNextRailroadSegment(); distance = 0; if (currentSegment == null) { currentSegment = startingSegment; } } rb.MovePosition(currentSegment.GetPointAtDistance(distance)); var rot = currentSegment.GetRotationAtDistance(distance); transform.rotation = Quaternion.Euler(0, rot.eulerAngles.y + 90, rot.eulerAngles.x + 90); distance += Time.deltaTime * Speed; }
public void SetStartingSegment(RailroadSegment segment) { currentSegment = startingSegment = segment; }