- Moved video screen into its own separate movie tent. - Adjusted stable post-processing volume. - Chickens are now at full volume. - Added button to toggle chickens off and on.
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Components;
|
|
using VRC.SDKBase;
|
|
|
|
namespace Pyralix.SkeeBall
|
|
{
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
|
|
public class Ball : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private AudioSource Speaker;
|
|
[SerializeField] private AudioClip BallCollisionClip;
|
|
[SerializeField] private bool HitSoundEnabled;
|
|
private VRCObjectSync objectSync;
|
|
private bool isColliding;
|
|
|
|
private const string
|
|
BallPrefix = "Ball";
|
|
|
|
private void Start()
|
|
{
|
|
objectSync = (VRCObjectSync)GetComponent(typeof(VRCObjectSync));
|
|
}
|
|
|
|
|
|
private void OnCollisionEnter(Collision other)
|
|
{
|
|
if(Utilities.IsValid(other) && other != null)
|
|
{
|
|
string otherName = other.gameObject.name;
|
|
|
|
if (otherName.Contains(BallPrefix) && HitSoundEnabled)
|
|
{
|
|
Speaker.PlayOneShot(BallCollisionClip, Mathf.Clamp01(other.relativeVelocity.magnitude / 2f));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _ResetBall()
|
|
{
|
|
Networking.SetOwner(Networking.LocalPlayer, objectSync.gameObject);
|
|
objectSync.Respawn();
|
|
}
|
|
}
|
|
}
|