In order to have less collision checks in my game, i'm trying to use Line Of Sight to disable collisions whenever Player, Enemy1, Enemy2 or Enemy3 is not in the block objects Line of Sight.
As you can see in the Demo.capx file, it works just fine with the current enemies, but if i create another instance of any of my enemies, it stops working.
The invisible/visible is only for visual illustration.
Could someone download the Demo.capx file, and write the right code, so it would work even when i create multiple instances of the same enemy.
Develop games in your browser. Powerful, performant & highly capable.
You can change your code like this:
But this whole approach is not very good. You can get much better results if you replace small blocks with big TiledBackground or TileMap object. In my test it reduced the number of collision checks by 90%!
If you want to go with individual blocks, you should repeat this LoS check every second or so, and not on every tick. Also, don't use Physics with Platform/Solid, these behaviors are not compatible and can cause all kinds of problems. At least don't enable them at the same time in one object.
Thank you for the information.