meta xr, auto fix, occlusion additions
This commit is contained in:
@@ -24,6 +24,9 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
private bool stopSoundPlayed = false;
|
||||
private float stopThreshold = 0.05f; // consider speed "0" when below this
|
||||
|
||||
private bool isBeingStoppedByPlayer = false;
|
||||
|
||||
|
||||
[Header("Tires")]
|
||||
public List<GameObject> FrontTires;
|
||||
public List<GameObject> BackTires;
|
||||
@@ -54,25 +57,26 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
|
||||
rollTires(); // Just an aesthetic improvement.
|
||||
|
||||
if (Quaternion.Angle(transform.rotation, desiredRotation) > 1f) // If the car is turning.
|
||||
if (!isBeingStoppedByPlayer)
|
||||
{
|
||||
if (!isTurning)
|
||||
if (Quaternion.Angle(transform.rotation, desiredRotation) > 1f)
|
||||
{
|
||||
AudioController.SetRPM(1300); //set externally in CarAudioController.cs
|
||||
setTireRotation(tireTurnAngle);
|
||||
if (!isTurning)
|
||||
{
|
||||
setTireRotation(tireTurnAngle);
|
||||
AudioController.SetRPM(1300);
|
||||
}
|
||||
isTurning = true;
|
||||
}
|
||||
|
||||
isTurning = true;
|
||||
}
|
||||
if (Quaternion.Angle(transform.rotation, desiredRotation) <= 1f) // Reset the turn value.
|
||||
{
|
||||
if (isTurning)
|
||||
else
|
||||
{
|
||||
AudioController.SetRPM(1450);
|
||||
setTireRotation(-tireTurnAngle);
|
||||
if (isTurning)
|
||||
{
|
||||
setTireRotation(-tireTurnAngle);
|
||||
AudioController.SetRPM(1450);
|
||||
}
|
||||
isTurning = false;
|
||||
}
|
||||
|
||||
isTurning = false;
|
||||
}
|
||||
|
||||
// Check if close enough to the waypoint
|
||||
@@ -85,12 +89,14 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
|
||||
if (StraightSpeed <= stopThreshold && !stopSoundPlayed)
|
||||
{
|
||||
stopSoundPlayed = true;
|
||||
|
||||
// Play the sound normally from your audio controller
|
||||
//AudioController.SetRPM(475);
|
||||
AudioController.PlayStopSound();
|
||||
|
||||
float currentRPM = AudioController.GetCurrentRPM();
|
||||
//Debug.LogError(currentRPM);
|
||||
if (currentRPM <= 550f) // confirms we are in the correct engine state
|
||||
{
|
||||
stopSoundPlayed = true;
|
||||
AudioController.PlayStopSound();
|
||||
//Debug.LogError("piiks");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,29 +126,29 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{;
|
||||
{
|
||||
if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
|
||||
StartCoroutine(SmoothAdjustSpeed(0, 0, haltspeed)); // Smoothly halt in 1 second
|
||||
//_tireSound.Stop();
|
||||
//_stopSound.Play();
|
||||
|
||||
isBeingStoppedByPlayer = true;
|
||||
|
||||
StartCoroutine(SmoothAdjustSpeed(0, 0, haltspeed));
|
||||
|
||||
AudioController.SetRPM(475);
|
||||
//AudioController.PlayStopSound();
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
|
||||
StartCoroutine(SmoothAdjustSpeed(targetSpeed, targetRotationSpeed, haltspeed)); // Smoothly resume speed in 1 second
|
||||
//_stopSound.Stop();
|
||||
//_tireSound.Play();
|
||||
|
||||
isBeingStoppedByPlayer = false;
|
||||
|
||||
StartCoroutine(SmoothAdjustSpeed(targetSpeed, targetRotationSpeed, haltspeed));
|
||||
|
||||
AudioController.SetRPM(1450);
|
||||
stopSoundPlayed = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator SmoothAdjustSpeed(float targetStraightSpeed, float targetRotationSpeed, float duration)
|
||||
{
|
||||
float initialStraightSpeed = StraightSpeed;
|
||||
|
||||
Reference in New Issue
Block a user