So i made a script for a weapon that when a player shoots it fires a ray cast. it can fire only every 0.4 seconds. The problem is that when it hits an entity that is shootable it throws max call stack exceeded.
https://playcanvas.com/editor/code/976292
Hey @Granted,
I’ve tracked the issue down to this line:
Network.socket.emit("checkshot", { "shooterid": Network.id, "shootername": this.username, "result": result });
More specifically, the issue only occurs if you include result
in the emitted packet. This is most likely because result
contains an entity
, which contains a reference to a component
that references the entity
again, generating a circular reference/loop. Thus Maximum call stack exceeded
.
I advise you to collect solely the data you need from the result and send that instead.
ok thank you