- Added a game manager for keeping score.

- Added concrete platforms to the horseshoes court.
- Simplified stable barrel collision. Not related to horseshoes. Sorry.
This commit is contained in:
2026-02-24 17:56:18 -05:00
parent 2a186247f5
commit 8c29052216
54 changed files with 6969 additions and 6485 deletions
@@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: HorseshoesGameManager
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 8dfc90ec8910e4546b6ecb3757c5c1e1,
type: 2}
udonAssembly:
assemblyError:
sourceCsScript: {fileID: 11500000, guid: 5d7046eafd3506f4a9933e3a1565a213, type: 3}
scriptVersion: 2
compiledVersion: 2
behaviourSyncMode: 4
hasInteractEvent: 0
scriptID: 1114807824005637898
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes:
- Name: fieldDefinitions
Entry: 7
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
UdonSharp.Editor]], mscorlib
- Name: comparer
Entry: 7
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
mscorlib]], mscorlib
- Name:
Entry: 8
Data:
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 60d0c7cd1036d6d45ad377a9ba047cf3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class HorseshoesGameManager : UdonSharpBehaviour
{
private const float IN_COUNT_DISTANCE = (0.0254f * 6);
private const int RINGER_POINT_VALUE = 3;
public void CalculatePoints(PlayerHorseshoe Shoe, float DistanceFromStake)
{
if (DistanceFromStake <= IN_COUNT_DISTANCE)
{
Debug.Log("[HorseshoesGameManager] Horseshoe is in count");
}
else
{
Debug.Log("[HorseshoesGameManager] Horseshoe is not in play");
}
}
public void CalculateRinger(PlayerHorseshoe Shoe)
{
Debug.Log("[HorseshoesGameManager] Ringer!");
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5d7046eafd3506f4a9933e3a1565a213
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+116 -56
View File
@@ -44,31 +44,37 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 7
Data: 8
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _ValidStakes
Data: _GameManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ValidStakes
Data: _GameManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Transform[], UnityEngine.CoreModule
Data: HorseshoesGameManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -83,13 +89,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 5|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -110,25 +116,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _HorseshoeRigidBody
Data: _ValidStakes
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _HorseshoeRigidBody
Data: _ValidStakes
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Rigidbody, UnityEngine.PhysicsModule
Data: UnityEngine.Transform[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -143,19 +149,10 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 9|UnityEngine.SpaceAttribute, UnityEngine.CoreModule
- Name: height
Entry: 4
Data: 8
- Name:
Entry: 8
Data:
Data: 1
- Name:
Entry: 7
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
@@ -179,31 +176,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _RingerDetector
Data: _HorseshoeRigidBody
- Name: $v
Entry: 7
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _RingerDetector
Data: _HorseshoeRigidBody
- Name: <UserType>k__BackingField
Entry: 7
Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: PlayerHorseshoeStakeDetection, Assembly-CSharp
Data: UnityEngine.Rigidbody, UnityEngine.PhysicsModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
Entry: 9
Data: 12
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -218,10 +209,19 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
Data: 2
- Name:
Entry: 7
Data: 14|UnityEngine.SpaceAttribute, UnityEngine.CoreModule
- Name: height
Entry: 4
Data: 8
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 15|UnityEngine.SerializeField, UnityEngine.CoreModule
@@ -245,19 +245,79 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _LeanDetector
Data: _RingerDetector
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _RingerDetector
- Name: <UserType>k__BackingField
Entry: 7
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: PlayerHorseshoeStakeDetection, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 19|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _LeanDetector
- Name: $v
Entry: 7
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _LeanDetector
- Name: <UserType>k__BackingField
Entry: 9
Data: 12
Data: 17
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -272,13 +332,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 18|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 22|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -302,16 +362,16 @@ MonoBehaviour:
Data: _DistanceDetectors
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _DistanceDetectors
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -326,13 +386,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 21|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 25|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -356,13 +416,13 @@ MonoBehaviour:
Data: _CheckMotion
- Name: $v
Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CheckMotion
- Name: <UserType>k__BackingField
Entry: 7
Data: 23|System.RuntimeType, mscorlib
Data: 27|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
@@ -371,7 +431,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 23
Data: 27
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -386,7 +446,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -410,13 +470,13 @@ MonoBehaviour:
Data: _CheckMotionTimer
- Name: $v
Entry: 7
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 29|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CheckMotionTimer
- Name: <UserType>k__BackingField
Entry: 7
Data: 26|System.RuntimeType, mscorlib
Data: 30|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
@@ -425,7 +485,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 26
Data: 30
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -440,7 +500,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 31|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
+60 -40
View File
@@ -8,6 +8,7 @@ using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.Continuous)]
public class PlayerHorseshoe : UdonSharpBehaviour
{
[SerializeField] private HorseshoesGameManager _GameManager;
[SerializeField] private Transform[] _ValidStakes;
[Space]
[SerializeField] private Rigidbody _HorseshoeRigidBody;
@@ -29,46 +30,7 @@ public class PlayerHorseshoe : UdonSharpBehaviour
_CheckMotionTimer += Time.fixedDeltaTime;
if (_CheckMotionTimer >= 0.5f)
{
_CheckMotion = false;
_CheckMotionTimer = 0.0f;
if (_RingerDetector.StakeCollision)
{
Debug.Log("[PlayerHorseshoe] Ringer!!!");
}
//else if (_LeanDetector.StakeCollision)
//{
// Debug.LogError("[PlayerHorseshoe] Leaning on stake.");
//}
else
{
// First, figure out which stake we're closest to
Vector3 ClosestStakePosition = Vector3.zero;
float ClosestStakeDistance = float.MaxValue;
foreach (Transform StakeTransform in _ValidStakes)
{
float DistanceToStake = Vector3.Distance(transform.position, StakeTransform.position);
if (DistanceToStake < ClosestStakeDistance)
{
ClosestStakeDistance = DistanceToStake;
ClosestStakePosition = StakeTransform.position;
}
}
// Then determine which distance detector is closest to this stake
float ClosestShoeDistance = float.MaxValue;
foreach (Transform DistanceDetector in _DistanceDetectors)
{
float DistanceToStake = Vector3.Distance(DistanceDetector.position, ClosestStakePosition);
if (DistanceToStake < ClosestShoeDistance)
{
ClosestShoeDistance = DistanceToStake;
}
}
// At this point, we know the shortest distance between the shoe and stake
Debug.Log("[PlayerHorseshoe] Detected distance: " + ClosestShoeDistance);
}
DetermineDistance();
}
}
else
@@ -77,6 +39,59 @@ public class PlayerHorseshoe : UdonSharpBehaviour
}
}
}
private void DetermineDistance()
{
if (_RingerDetector.StakeCollision)
{
_GameManager.CalculateRinger(this);
}
//else if (_LeanDetector.StakeCollision)
//{
// Debug.LogError("[PlayerHorseshoe] Leaning on stake.");
//}
else
{
// First, figure out which stake we're closest to
Vector3 ClosestStakePosition = Vector3.zero;
float ClosestStakeDistance = float.MaxValue;
foreach (Transform StakeTransform in _ValidStakes)
{
float DistanceToStake = Vector3.Distance(transform.position, StakeTransform.position);
if (DistanceToStake < ClosestStakeDistance)
{
ClosestStakeDistance = DistanceToStake;
ClosestStakePosition = StakeTransform.position;
}
}
// Then determine which distance detector is closest to this stake
float ClosestShoeDistance = float.MaxValue;
foreach (Transform DistanceDetector in _DistanceDetectors)
{
// Change Y value to 0 for all positions, so we only measure lateral position.
Vector3 DistanceDetectorPositionLateral = DistanceDetector.position;
DistanceDetectorPositionLateral.y = 0.0f;
Vector3 ClosestStakePositionLateral = ClosestStakePosition;
ClosestStakePositionLateral.y = 0.0f;
float DistanceToStake = Vector3.Distance(DistanceDetectorPositionLateral, ClosestStakePositionLateral);
if (DistanceToStake < ClosestShoeDistance)
{
ClosestShoeDistance = DistanceToStake;
}
}
// Subtract half an inch from the measurement, since we measure from the
// centre of the 1" diameter stake
ClosestShoeDistance -= (0.0254f / 2.0f);
_GameManager.CalculatePoints(this, ClosestShoeDistance);
//Debug.Log("[PlayerHorseshoe] Detected distance: " + ClosestShoeDistance);
}
StopCheckingMotion();
}
public override void OnDrop()
{
@@ -88,4 +103,9 @@ public class PlayerHorseshoe : UdonSharpBehaviour
_CheckMotion = true;
_CheckMotionTimer = 0.0f;
}
public void StopCheckingMotion()
{
_CheckMotion = false;
_CheckMotionTimer = 0.0f;
}
}