Skip to content

Fixed NetworkCollider bug to allow for comparisons between current tick and last tick stored sets - #1041

Merged
FirstGearGames merged 2 commits into
FirstGearGames:mainfrom
strakerak:main
Aug 9, 2026
Merged

FirstGearGames merged 2 commits into
FirstGearGames:mainfrom
strakerak:main

Conversation

@strakerak

Copy link
Copy Markdown
Contributor

From the 4.7.2 update, the IL2CPP code was added while checking if lastTick was not unsetLastTick (max value). If this condition passed, localTick would be removed from the _enteredColliders HashSet. However, this is ran after adding everything to localtick, so it would render that entire entry useless.

Whenever it would check for LastEnteredColliders in either method, it would resolve to Null as there is no entry in the HashSet from the lastTick, ONLY the current localTick can be accessed within that code snippet.

So anytime that code snippet is ran, it would always resolve to OnEnters, but no OnStays or OnExits.

Changing it from localTick back to lastTick (as it was changed to localTick in the recent update) fixed this, and now both OnStays and OnExits are called.

Found when entering a platform on my game, and it kept me as a parent even though I ran far away from it, nothing in OnExit would be called, and I thought it wasn't subscribing at first. Turns out it was just an access issue for comparisons.

Long description because reading through the entire code allows me to understand more about how it works on the Networking Side, it's a lot of fun!

strakerak added 2 commits May 15, 2026 16:37
Changed localTick to lastTick for removal after collider comparisons are run. If removing localTick, lastTick cannot be found or accessed, hence removing any ability to run comparisons.
@aaronkwan

Copy link
Copy Markdown
Contributor

@strakerak nice catch, explains why I was also running into this bug!

Note: I believe your fix is incomplete; you also need to change the localTick to lastTick in the TryGetValueIL2CPP call.

Something like this:

if (lastTick is not unsetLastTick && _enteredColliders.TryGetValueIL2CPP(localTick, out HashSet<Collider2D> lEnteredColliders))

becomes

if (lastTick is not unsetLastTick && _enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider2D> lEnteredColliders))

@strakerak

strakerak commented May 26, 2026 via email

Copy link
Copy Markdown
Contributor Author

@FirstGearGames
FirstGearGames merged commit bca57bd into FirstGearGames:main Aug 9, 2026
FirstGearGames pushed a commit that referenced this pull request Sep 2, 2026
- Fixed ZigZagDecode improperly decoding values in IL2CPP with specific backing CPP libraries.
- Fixed Scene object expecting prefab ID (#1032).
- Fixed eliminated or significantly reduced wobble in local reconcile resimulations on server-authoritative objects.
- Fixed NetworkAnimator delay/desync on host owned object, observed by clients (#1062).
- Fixed NetworkCollider/2D tick comparison error (#1041).
- Fixed prefab objects generator cannot include folders with spaces in the path (#1045).
- Fixed large writers pooling incorrectly, causing them to not be re-used (#1054).
- Fixed LiteNetLib wrong data length after BasePacketLayer modification (#1064).
- Fixed NetworkTrigger2D by uncommenting entire file.
- Fixed nested NetworkObjects not spawning recursively when spawned via OnStartServer of their parent.
- Fixed SyncType values being reset to default before OnStopServer as clientHost (#1036).
- Fixed disconnecting clients not being cleared on Transport shutdown (#1044).
- Fixed Quaternion ScaleToFloat helper math, cause of marginal rotational errors (#1067).
- Fixed loading scenes by path not loading the scene for clients under certain conditions (#1060).
- Obsoleted SceneLookupData.Name in favor of SceneLookupData.FullName.
- Added NetworkBehaviour.ToString null safety (#1046).
- Added Unity 6.5 scene handle change support (#1052 / #1051 merge).
- Added Unity 6.5 GetEntityId/GetInstanceId support.
- Added NetworkCollider2D use PhysicsScene2D.OverlapCollider as a fallback (#1042).
- Added NetworkCollider/2D.RemoveEnteredCollider.
- Added NetworkCollider/2D InvokeStayOnEnter.
- Added NetworkAnimator channel option - under Beta menu, Animator Channel (#1039).
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.

3 participants