Working pretty well

This commit is contained in:
2026-01-03 20:02:17 +01:00
parent a88e4bde81
commit 06c26eb03e
8 changed files with 2353 additions and 1283 deletions

View File

@@ -2,7 +2,9 @@
using Marro.PacManUdon;
using System;
using System.Drawing.Text;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using VRC.SDKBase;
@@ -32,10 +34,15 @@ public class TestBall : SyncedObject
private float amountUp = 0;
private int loopOffset = 0;
private float[] jumps;
private int jumpsIndex;
public void Initialize(NetworkManager networkManager)
{
this.networkManager = networkManager;
sumOfDt = networkManager.SyncedTime;
jumps = new float[10];
jumpsIndex = 0;
}
public override void SyncedUpdate()
@@ -55,6 +62,19 @@ public class TestBall : SyncedObject
amountUp = Mathf.Clamp(amountUp + delta, 0, 1);
}
private void Jump()
{
DeltaUp(UpPerPress);
jumps[jumpsIndex++] = GetProgress();
jumps[jumpsIndex++] = amountUp;
if (jumpsIndex == jumps.Length)
{
jumpsIndex = 0;
}
}
private void SetProgress(float progress)
{
var currentTimestamp = GetCurrentTimestamp();
@@ -101,7 +121,7 @@ public class TestBall : SyncedObject
public void UpButtonPressed()
{
DeltaUp(UpPerPress);
Jump();
Debug.Log($"({nameof(TestBall)}) Up button pressed, jumped up at {GetProgress()} to {amountUp}.");
}
@@ -126,10 +146,26 @@ public class TestBall : SyncedObject
}
else
{
DeltaUp(UpPerPress);
Jump();
Debug.Log($"({nameof(TestBall)}) Received up event, jumped up at {GetProgress()} to {amountUp}.");
}
return true;
}
public void WriteDebugOutput(TMP_InputField debugOutput)
{
string jumpsText = "";
for (int i = 0; i < jumps.Length; i += 2)
{
jumpsText += $"{i/2}. ({jumps[i]}, {jumps[i + 1]}), ";
}
debugOutput.text += $"{nameof(TestBall)} {mode}:\n" +
$"Progress: {GetProgress()}\n" +
$"Up: {amountUp}\n" +
$"SumOfDt: {sumOfDt}\n" +
$"Jumps: {jumpsText}\n" +
$"\n";
}
}