[SOLVED] Rigid body issue


I am following tutorial for multiplayer and I am having issues with finding what is the problem. When I run the application with socket.io library where I host on Glitch, it shows error that rigid body is null.


Can someone look what is wrong here? I can’t see what is the issue

Forgot to add my Glitch project.

1 Like

Hi @fingerzz! Can you show the error please?

[network.js?id=52287955&branchId=5b48683d-757e-43c4-a6a9-4330ca3ef324:76]: Uncaught TypeError: Cannot read property 'rigidbody' of null

TypeError: Cannot read property 'rigidbody' of null
    at scriptType.Network.pohybHrace (https://launch.playcanvas.com/api/assets/files/Scripts/network.js?id=52287955&branchId=5b48683d-757e-43c4-a6a9-4330ca3ef324:76:36)
    at f. (https://launch.playcanvas.com/api/assets/files/Scripts/network.js?id=52287955&branchId=5b48683d-757e-43c4-a6a9-4330ca3ef324:22:14)
    at f.r.emit (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:2617)
    at f.value (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:35589)
    at f.value (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:30035)
    at f.value (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:29741)
    at f.value (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:29370)
    at y.r.emit (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:2617)
    at y.value (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:35791)
    at y.value (https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js:6:16871)

I think the problem is not the rigidbody itself but the entity of it. Check which line the error gives and find out if the entity exist.

It causes error at network.js line 76. But i don’t know how to find out if entity exists.

I am getting the same error when trying your project. The debugger shows that your this.hraci list is missing the incoming object:

I imagine that’s the list where you hold the player entities created right? Check if you are creating the entity and adding it in that list before attempting to access it.

1 Like

Thanks for answer about it. I found that I had typo in the code. Now it is working properly!

1 Like