How do I avoid this multiplayer bug "Cannot read properties of null?"

0 favourites
  • 9 posts
From the Asset Store
Weapon System
$18 USD
10% off
Weapon System is a Construct behavior that serves as manager of weapons and their properties.
  • Hello,

    I'm building a multiplayer game on C3 v276.2 stable, and I seem to be having a problem. Every so often, when an enemy object is destroyed by the host, a peer in the game is likely to freeze and receive the following error in console: runtime.js:62 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'GetInstances'). This error basically loops forever. I'm using the same basic code as in the real-time multiplayer tutorial example, has anyone had something like this happen to them? This happens over the internet and while simulating lag, but not on regular local testing. Any thoughts for how I can stop this from happening? Any help is appreciated. Thanks!

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is what things look like for the host and the peer:

    This is what the console is saying over and over:

    Thanks!

  • On further review, it looks like the peer is continuously trying to destroy something that isn't there? It says that I have -15,000 objects after leaving it be for a little while, and that number rises by around -250 every second:

    Whereas I have a steady number of objects for the host.

    Any ideas?

  • Here's a .c3p file that should help illustrate what's going on. Should be pretty simple.

    drive.google.com/file/d/121Gd9Txixt-Cw8cLMemnyYzNgxaUAYdU/view

    Thanks!

  • As an update, it still happens in r285 stable.

    Although I'd like to fix this, I'd also like to offer players a way to get out of the game if this happens. Right now trying to disconnect from the multiplayer room doesn't work as it should, and the next steps in the process don't fire (doesn't disconnect from signalling server etc.). Is there a condition that I could include that would capture this scenario? If so I could give players a button to just completely disconnect entirely.

  • Are you using the correct disconnect action? There are two. IIRC you can disconnect from the signalling room/server without disconnecting from the host-peer connection, which may result in certain signalling triggers not working as expected.

  • In a normal playthrough, yes, the disconnect flow works as intended. It's just when this error occurs that attempting to disconnect fails.

  • Any chance that there are more things that I can look at in the debugger for Multiplayer? Right now when I view the Multiplayer object in the debugger it just says it's on or not, but nothing like whether you're connected to the signalling server, if you've joined the room, any packet losses, etc.

  • I would not hold my breath on anything official. When working on multiplayer projects, I often made my own debugging text/textbox for whatever I needed to see or figure out.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)