private void Start() { world = pipeWorld.transform.parent; rotator = transform.GetChild(0); currentPipe = pipeWorld.SetupFirstPipe(); SetupCurrentPipe(); }
public void Position(PipeInstance pipeInstance, float curveRotation, float ringRotation) { transform.SetParent(pipeInstance.transform, false); transform.localRotation = Quaternion.Euler(0f, 0f, -curveRotation); rotator.localPosition = new Vector3(0f, pipeInstance.CurveRadius); rotator.localRotation = Quaternion.Euler(ringRotation, 0f, 0f); }
public override void GenerateItems(PipeInstance pipeInstance) { float angleStep = pipeInstance.CurveAngle / pipeInstance.CurveSegmentCount; for (int i = 0; i < pipeInstance.CurveSegmentCount; i++) { Obstacle obstacle = Instantiate<Obstacle>(obstacles[Random.Range(0, obstacles.Length)]); float pipeRotation = (Random.Range(0, pipeInstance.pipeSegmentCount) + 0.5f) * 360f / pipeInstance.pipeSegmentCount; obstacle.Position(pipeInstance, i * angleStep, pipeRotation); } }
public void AlignWidth(PipeInstance pipeInstance) { relativeRotation = Random.Range(0, curveSegmentCount) * 360f / pipeSegmentCount; transform.SetParent(pipeInstance.transform, false); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.Euler(0f, 0f, -pipeInstance.curveAngle); transform.Translate(0f, pipeInstance.curveRadius, 0f); transform.Rotate(relativeRotation, 0f, 0f); transform.Translate(0f, -curveRadius, 0f); transform.SetParent(pipeInstance.transform.parent); transform.localScale = Vector3.one; }
private void Update() { float delta = velocity * Time.deltaTime; distanceTraveled += delta; systemRotation += delta * deltaToRotation; if (systemRotation >= currentPipe.CurveAngle) { delta = (systemRotation - currentPipe.CurveAngle) / deltaToRotation; currentPipe = pipeWorld.SetupNextPipe(); SetupCurrentPipe(); deltaToRotation = 360f / (2f * Mathf.PI * currentPipe.CurveRadius); systemRotation = delta * deltaToRotation; } pipeWorld.transform.localRotation = Quaternion.Euler(0f, 0f, systemRotation); UpdateAvatarRotation(); UpDownMovement(); }
public abstract void GenerateItems(PipeInstance pipeInstance);