Map markers now freeze on two failures or one success, and are more accurate.

This commit is contained in:
Jamie Greunbaum 2025-06-22 16:28:34 -04:00
parent 557ec5b239
commit f69cb5350c
7 changed files with 8198 additions and 271 deletions

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@ SphereCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.05
m_Radius: 0.1
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &1902543354252190736
MonoBehaviour:
@ -133,7 +133,7 @@ Transform:
m_GameObject: {fileID: 9138048797662084823}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.02545, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.01, y: 1, z: 0.01}
m_ConstrainProportionsScale: 0
m_Children: []

File diff suppressed because it is too large Load Diff

View File

@ -44,19 +44,19 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 5
Data: 7
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _IsGrabbed
Data: _Enabled
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _IsGrabbed
Data: _Enabled
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
@ -80,13 +80,13 @@ MonoBehaviour:
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
Data: 3
- Name:
Entry: 7
Data: 5|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
@ -95,7 +95,73 @@ MonoBehaviour:
Data:
- Name:
Entry: 7
Data: 6|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 7|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- 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: _IsGrabbed
- Name: $v
Entry: 7
Data: 8|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _IsGrabbed
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 10|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 11|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@ -119,13 +185,13 @@ MonoBehaviour:
Data: _GameManager
- Name: $v
Entry: 7
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _GameManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 8|System.RuntimeType, mscorlib
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: GameManagerRound3, Assembly-CSharp
@ -134,7 +200,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 9|System.RuntimeType, mscorlib
Data: 14|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
@ -155,13 +221,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 10|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 11|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 16|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@ -185,13 +251,13 @@ MonoBehaviour:
Data: _AudioManager
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _AudioManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
Data: 18|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: AudioManager, Assembly-CSharp
@ -200,7 +266,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 9
Data: 14
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@ -215,13 +281,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 15|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 20|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@ -245,13 +311,13 @@ MonoBehaviour:
Data: _CollidingLocations
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollidingLocations
- Name: <UserType>k__BackingField
Entry: 7
Data: 17|System.RuntimeType, mscorlib
Data: 22|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataList, VRCSDK3
@ -260,7 +326,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 17
Data: 22
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@ -275,7 +341,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@ -299,13 +365,13 @@ MonoBehaviour:
Data: _CollisionCheckCounter
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollisionCheckCounter
- Name: <UserType>k__BackingField
Entry: 7
Data: 20|System.RuntimeType, mscorlib
Data: 25|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
@ -314,7 +380,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 20
Data: 25
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@ -329,7 +395,55 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- 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: _FailureCounter
- Name: $v
Entry: 7
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FailureCounter
- Name: <UserType>k__BackingField
Entry: 9
Data: 25
- Name: <SystemType>k__BackingField
Entry: 9
Data: 25
- 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: false
- Name: _fieldAttributes
Entry: 7
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0

View File

@ -3,11 +3,13 @@ using UdonSharp;
using UnityEngine;
using VRC.SDK3.Components;
using VRC.SDK3.Data;
using static UnityEditor.FilePathAttribute;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class FloorMapMarker : UdonSharpBehaviour
{
[UdonSynced, SerializeField, FieldChangeCallback(nameof(Enabled))] private bool _Enabled = false;
[UdonSynced, FieldChangeCallback(nameof(IsGrabbed))] private bool _IsGrabbed = false;
[SerializeField] private GameManagerRound3 _GameManager;
@ -15,8 +17,11 @@ public class FloorMapMarker : UdonSharpBehaviour
private DataList _CollidingLocations = new DataList();
private int _CollisionCheckCounter = 0;
private int _FailureCounter = 0;
private const int MAX_REPEAT_COLLISION_CHECKS = 3;
private const float TIME_BETWEEN_REPEAT_COLLISION_CHECKS = 0.15f;
private const int MAX_FAILURE_COUNT = 2;
public void OnTriggerEnter(Collider OtherCollider)
@ -24,15 +29,31 @@ public class FloorMapMarker : UdonSharpBehaviour
FloorMapLocation Location = OtherCollider.GetComponent<FloorMapLocation>();
if (Location != null)
{
Debug.LogError("Found " + Location.City + ", " + Location.Country);
_CollidingLocations.Add(Location);
_CollisionCheckCounter = 0;
if (!IsGrabbed) CheckCollisions();
}
}
public void OnTriggerExit(Collider OtherCollider)
{
FloorMapLocation Location = OtherCollider.GetComponent<FloorMapLocation>();
if (Location != null)
{
_CollidingLocations.Remove(Location);
_CollisionCheckCounter = 0;
}
}
public override void OnPickup()
{
Rigidbody Body;
if (Body = GetComponent<Rigidbody>())
{
Body.constraints = RigidbodyConstraints.None;
}
Enabled = true;
IsGrabbed = true;
_CollidingLocations.Clear();
@ -50,6 +71,8 @@ public class FloorMapMarker : UdonSharpBehaviour
public void CheckCollisions()
{
if (!Enabled) return;
if (_CollidingLocations.Count > 0 && IsUpright() && !IsGrabbed)
{
for (int i = 0; i < _CollidingLocations.Count; i++)
@ -61,13 +84,17 @@ public class FloorMapMarker : UdonSharpBehaviour
if (FoundCorrectResponse)
{
_AudioManager.PlaySFX(SFXEventType.MapCorrect);
VRCPickup Pickup;
if (Pickup = GetComponent<VRCPickup>())
{
Pickup.pickupable = false;
}
Rigidbody Body;
if (Body = GetComponent<Rigidbody>())
{
Body.constraints = RigidbodyConstraints.FreezeAll;
}
transform.position = Location.transform.position;
StandUpright();
Enabled = false;
EnablePickup(false);
return;
}
@ -84,9 +111,24 @@ public class FloorMapMarker : UdonSharpBehaviour
{
_AudioManager.PlaySFX(SFXEventType.MapIncorrect);
Rigidbody Body;
if (Body = GetComponent<Rigidbody>())
{
Body.constraints = RigidbodyConstraints.FreezeAll;
}
StandUpright();
_CollisionCheckCounter = 0;
transform.eulerAngles = new Vector3(-90.0f, 0.0f, 0.0f);
_CollidingLocations.Clear();
// Stop checking for new collisions here, and if this results
// in too many fails, don't allow new pickups.
Enabled = false;
_FailureCounter++;
if (_FailureCounter >= MAX_FAILURE_COUNT)
{
EnablePickup(false);
}
}
_CollisionCheckCounter++;
}
@ -110,21 +152,35 @@ public class FloorMapMarker : UdonSharpBehaviour
return false;
}
private bool IsUpright()
private void EnablePickup(bool Enable)
{
return (Vector3.Dot(transform.forward, Vector3.up) >= 0.85f);
VRCPickup Pickup;
if (Pickup = GetComponent<VRCPickup>())
{
Pickup.pickupable = Enable;
}
}
//public bool Enabled
//{
// set
// {
// _Enabled = value;
// }
// get => _Enabled;
//}
private void StandUpright()
{
transform.eulerAngles = new Vector3(0.0f, transform.eulerAngles.y, 0.0f);
}
private bool IsUpright()
{
return (Vector3.Dot(transform.up, Vector3.up) >= 0.85f);
}
public bool Enabled
{
set
{
_Enabled = value;
}
get => _Enabled;
}
public bool IsGrabbed
{