feat: polish VR gameplay and sync tools
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using Platinio;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.SceneManagement;
|
||||
using VRBeats.ScriptableEvents;
|
||||
using VRSDK;
|
||||
|
||||
@@ -60,24 +62,22 @@ namespace VRBeats
|
||||
Vector3 finalPosition = CalculateSpawnPosition( info.position);
|
||||
Vector3 travelOffset = Vector3.forward * -settings.TargetTravelDistance;
|
||||
Vector3 spawnPosition = finalPosition - travelOffset;
|
||||
|
||||
Spawneable clone = Instantiate( spawneable , spawnPosition , Quaternion.Euler( info.rotation ) );
|
||||
SetSpeedRelativeToPlayZone(info);
|
||||
clone.Construct(info);
|
||||
|
||||
Vector3 finalScale = clone.transform.localScale;
|
||||
clone.transform.localScale = Vector3.zero;
|
||||
|
||||
float travelTime = info.travelTimeOverride > 0f ? info.travelTimeOverride : settings.TargetTravelTime;
|
||||
|
||||
clone.transform.Move(finalPosition, travelTime).SetEase(settings.TargetTravelEase).SetOnComplete(delegate
|
||||
{
|
||||
info.speed = settings.TargetTravelDistance / Mathf.Max(0.05f, travelTime);
|
||||
SetSpeedRelativeToPlayZone(info);
|
||||
|
||||
Spawneable clone = Instantiate( spawneable , spawnPosition , Quaternion.Euler( info.rotation ) );
|
||||
clone.Construct(info);
|
||||
StartCoroutine(BeginContinuousSpawnNextFrame(clone));
|
||||
}
|
||||
|
||||
private IEnumerator BeginContinuousSpawnNextFrame(Spawneable clone)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
if (clone != null)
|
||||
clone.OnSpawn();
|
||||
}).SetUpdateMode(Platinio.TweenEngine.UpdateMode.Update);
|
||||
|
||||
|
||||
clone.transform.ScaleTween(finalScale, travelTime).SetEase(settings.TargetTravelEase);
|
||||
|
||||
}
|
||||
|
||||
private void SetSpeedRelativeToPlayZone(SpawnEventInfo info)
|
||||
@@ -122,13 +122,7 @@ namespace VRBeats
|
||||
|
||||
public void RestartLevel()
|
||||
{
|
||||
gameObject.CancelAllTweens();
|
||||
|
||||
isGameRunning = true;
|
||||
audioManager.SetAudioMixerPitch(1.0f);
|
||||
enviromentController.TurnLightsOn();
|
||||
playableDirector.time = 0.0f;
|
||||
playableDirector.Play();
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user