Further input latency fixes

This commit is contained in:
Starpelly 2021-12-24 21:37:03 -05:00
parent 58ea8d5e4c
commit db79325393
7 changed files with 73 additions and 27 deletions

View File

@ -4200,6 +4200,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 992902363} - component: {fileID: 992902363}
- component: {fileID: 992902364} - component: {fileID: 992902364}
- component: {fileID: 992902365}
m_Layer: 0 m_Layer: 0
m_Name: Circle m_Name: Circle
m_TagString: Untagged m_TagString: Untagged
@ -4272,6 +4273,19 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!114 &992902365
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 992902362}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a761d8a407e1d9d49afaed94b793ed75, type: 3}
m_Name:
m_EditorClassIdentifier:
rotateSpeed: 55
--- !u!1 &1044718271 --- !u!1 &1044718271
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -47,7 +47,7 @@ namespace RhythmHeavenMania
public static Conductor instance; public static Conductor instance;
//Pause times //Pause times
private int pauseTime = 0; // private int pauseTime = 0;
public float beatThreshold; public float beatThreshold;

View File

@ -130,7 +130,7 @@ namespace RhythmHeavenMania
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.LogWarning("Event not found! May be spelled wrong or it is not implemented."); Debug.LogWarning("Event not found! May be spelled wrong or it is not implemented." + ex);
} }
} }

View File

@ -88,17 +88,20 @@ namespace RhythmHeavenMania.Games.ClappyTrio
for (int i = 0; i < Lion.Count; i++) for (int i = 0; i < Lion.Count; i++)
{ {
float minus = 0; float length = currentClappingLength * (i);
float lengthplusone = (currentClappingLength * (i + 1));
// i spent like 25 minutes trying to figure out what was wrong with this when i forgot to subtract the currentClapLength :( // i spent like 25 minutes trying to figure out what was wrong with this when i forgot to subtract the currentClapLength :(
if (i == Lion.Count - 1) if (i == Lion.Count - 1)
minus = Minigame.perfectTime; {
length = 0;
}
if (songPosBeat > lastClapStart + (currentClappingLength * (i) - minus) && songPosBeat < lastClapStart + (currentClappingLength * (i + 1)) && clapIndex == i) if (songPosBeat > lastClapStart + length && songPosBeat < lastClapStart + lengthplusone && clapIndex == i)
{ {
if (i == Lion.Count - 1) if (i == Lion.Count - 1)
{ {
ClappyTrioPlayer.SetClapAvailability(lastClapStart + (currentClappingLength * i - Minigame.perfectTime)); ClappyTrioPlayer.SetClapAvailability(lastClapStart + (currentClappingLength * (i - 1)), currentClappingLength);
clapIndex = 0; clapIndex = 0;
isClapping = false; isClapping = false;

View File

@ -13,6 +13,7 @@ namespace RhythmHeavenMania.Games.ClappyTrio
public bool late; public bool late;
private float lastClapBeat; private float lastClapBeat;
private float lastClapLength;
[SerializeField] private bool clapVacant; [SerializeField] private bool clapVacant;
private int lastIndex; private int lastIndex;
@ -36,36 +37,47 @@ namespace RhythmHeavenMania.Games.ClappyTrio
Clap(); Clap();
} }
// if (clapVacant == true) if (clapVacant == true)
{ {
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(lastClapBeat, 1f)); float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(lastClapBeat, lastClapLength));
print(normalizedBeat);
if (normalizedBeat > Minigame.earlyTime && normalizedBeat < Minigame.perfectTime && lastIndex == 0) if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastIndex == 0)
{ {
SetEligibility(true, false, false); SetEligibility(true, false, false);
lastIndex++; lastIndex++;
} }
else if (normalizedBeat > Minigame.perfectTime && normalizedBeat < Minigame.lateTime && lastIndex == 1) else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastIndex == 1)
{ {
SetEligibility(false, true, false); SetEligibility(false, true, false);
// Clap(); // Clap();
lastIndex++; lastIndex++;
} }
else if (normalizedBeat > Minigame.lateTime && lastIndex == 2) else if (normalizedBeat > Minigame.LateTime() && lastIndex == 2)
{ {
SetEligibility(false, false, true); SetEligibility(false, false, true);
clapVacant = false; clapVacant = false;
lastIndex = 0; lastIndex = 0;
lastClapLength = 0;
lastClapBeat = 0;
hit = false; hit = false;
ClearLog();
} }
} }
} }
public void SetClapAvailability(float startBeat) public void ClearLog()
{
var assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.Editor));
var type = assembly.GetType("UnityEditor.LogEntries");
var method = type.GetMethod("Clear");
method.Invoke(new object(), null);
}
public void SetClapAvailability(float startBeat, float length)
{ {
lastClapBeat = startBeat; lastClapBeat = startBeat;
clapVacant = true; clapVacant = true;
lastClapLength = length;
} }
private void SetEligibility(bool early, bool perfect, bool late) private void SetEligibility(bool early, bool perfect, bool late)
@ -96,6 +108,7 @@ namespace RhythmHeavenMania.Games.ClappyTrio
} }
else else
{ {
print(early + " " + perfect + " " + late);
clapEffect.SetActive(false); clapEffect.SetActive(false);
Jukebox.PlayOneShot("miss"); Jukebox.PlayOneShot("miss");
ClappyTrio.instance.playerHitLast = false; ClappyTrio.instance.playerHitLast = false;

View File

@ -38,43 +38,38 @@ namespace RhythmHeavenMania.Games.ForkLifter
private void Update() private void Update()
{ {
float normalizedBeatAnim = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f)); float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f);
anim.Play("Flicked_Object", -1, normalizedBeatAnim); anim.Play("Flicked_Object", -1, normalizedBeatAnim);
anim.speed = 0; anim.speed = 0;
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2f)); float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2f);
float earlyTime = Minigame.earlyTime * 2; print(normalizedBeat + " " + Minigame.PerfectTime());
float perfectTime = Minigame.perfectTime * 2;
float lateTime = Minigame.lateTime * 2;
float endTime = Minigame.endTime * 2;
print(normalizedBeat + " " + perfectTime);
// Early State // Early State
if (normalizedBeat > earlyTime && normalizedBeat < perfectTime && estate <= 1) if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && estate <= 1)
{ {
MakeEligible(true, false, false); MakeEligible(true, false, false);
estate++; estate++;
} }
// Perfect State // Perfect State
else if (normalizedBeat > perfectTime && normalizedBeat < lateTime && pstate <= 1) else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && pstate <= 1)
{ {
MakeEligible(false, true, false); MakeEligible(false, true, false);
pstate++; pstate++;
} }
// Late State // Late State
else if (normalizedBeat > lateTime && normalizedBeat < endTime && lstate <= 1) else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lstate <= 1)
{ {
MakeEligible(false, false, true); MakeEligible(false, false, true);
lstate++; lstate++;
} }
else if (normalizedBeat < earlyTime || normalizedBeat > endTime) else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
{ {
MakeInEligible(); MakeInEligible();
} }
if (normalizedBeat > endTime && endstate <= 1) if (normalizedBeat > Minigame.EndTime() && endstate <= 1)
{ {
endstate++; endstate++;
Jukebox.PlayOneShot("audience/disappointed"); Jukebox.PlayOneShot("audience/disappointed");

View File

@ -6,7 +6,28 @@ namespace RhythmHeavenMania.Games
{ {
public class Minigame : MonoBehaviour public class Minigame : MonoBehaviour
{ {
public static float earlyTime = 0.38f, perfectTime = 0.41f, lateTime = 0.535f, endTime = 1f; public static float earlyTime = 0.77f, perfectTime = 0.87f, lateTime = 1.09f, endTime = 1.15f;
// hopefully these will fix the lowbpm problem
public static float EarlyTime()
{
return earlyTime;
}
public static float PerfectTime()
{
return perfectTime;
}
public static float LateTime()
{
return lateTime;
}
public static float EndTime()
{
return endTime;
}
public int firstEnable = 0; public int firstEnable = 0;