How to stop calculating entities at distance

is there some script i could implement into the player that only renders entities with a dynamic rigidbody when they are a certain distance from the player, or perhaps disables all entities with a dynamic rigidbody when they are far away or something similar to this?


You can calculate their distance from the active camera and act accordingly:

const distanceFromCamera = this.cameraEntity.getPosition().distance(this.entity.getPosition());

if(distanceFromCamera > 100.0){

Similarly for the dynamic rigid bodies, although if they sleep at that distance (they are not moving) then you may not have to do anything. The physics engine internally may be optimizing that, so test and profile.

For the distance calculation there are some optimizations to do it faster since there is a slight cost calling that method for many objects per frame (search for using lengthSq instead).