private void SpawnStep(int index, StepAndSpawn position, StepAndSpawn lookAt) { Vector3 toPlace = new Vector3(position.SpawnPoint.x, position.SpawnPoint.y - DominoHeight / 2, position.SpawnPoint.z); Vector3 targetPosition = lookAt.GetCopyOfSpawnPoint(); targetPosition.y = toPlace.y; GameObject step = Instantiate(Step, toPlace, Quaternion.identity); step.transform.LookAt(targetPosition); if (position.Step) { DestroyObject(position.Step); position.Step = null; } position.Step = step; _spawnList[index] = position; }
private void GenerateSpawnPoints() { float currentDistance; float targetDistance = 0.0f; for (int i = 0; i < _interpolatedValues.Count; i++) { currentDistance = _distances[i]; if (currentDistance >= targetDistance) { StepAndSpawn temp = new StepAndSpawn(); Vector3 tempVector3 = i == 0 ? _interpolatedValues[i] : _interpolatedValues[i - 1]; tempVector3.y = 0.9375f; temp.SpawnPoint = tempVector3; _spawnList.Add(temp); targetDistance += DistanceBetweenDominos; } } }