Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple colliders on the same object for VoiceOverrideTriggerZone #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

techanon
Copy link

No description provided.

Comment on lines +26 to +27
private int[] playerIds = new int[82];
private int[] colliderStacks = new int[82];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use DataList or better a DataDictionary instead of arrays, key is playerid, value is stacksize.

public override void Start() {
base.Start();
// ensure that players already being inside the trigger before udon starts are detected by disabling them
// once and enabling them 1 frame later again
_allTrigger = gameObject.GetComponents<Collider>();
DisableAllTrigger();
SendCustomEventDelayedFrames(nameof(EnableAllTriggerDelayed), 1, EventTiming.LateUpdate);
SendCustomEventDelayedSeconds(nameof(TriggerStayCheck), 1f, EventTiming.LateUpdate);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the scene setup this can have a major impact on performance when many zones update all at once.

Additionally, is guaranteed that this custom loop keeps running should this script be disabled?

}
}

private void expand(ref int[] stale, int newSize)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed if DataDictionary is used

// This ensures continuity for edge cases like players entering stations while in the trigger zone.
public void TriggerStayCheck()
{
SendCustomEventDelayedSeconds(nameof(TriggerStayCheck), 5f);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe randomizing the delay can prevent a sudden lag spike accross all zones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants