How do I disable collisions on offscreen sprites

  • So, I have 2 sprites with lot of instances on layout (total of 120) and all of them are solids with collision enabled. Since this uses a lot of CPU to check collisions, I was wondering is there a way to disable collisions on instances that are off screen. I've tried something like "Sprite is (not)on screen -> collision disabled" but this diables collisions on all instances, both on screen and off screen.

    Any ideas?

  • You could always hack it.. make an invisible sprite the size of the screen (make it follow camera if scene is large) and use Is-overlapping sprite to condition out ones that are off-scene.. there are more legit ways to do this but I like hacks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hmmmm, interesitng will try it and see the impact on performance... Tnx!

  • So, I have 2 sprites with lot of instances on layout (total of 120) and all of them are solids with collision enabled. Since this uses a lot of CPU to check collisions, I was wondering is there a way to disable collisions on instances that are off screen. I've tried something like "Sprite is (not)on screen -> collision disabled" but this diables collisions on all instances, both on screen and off screen.

    Any ideas?

    " Sprite is (not) on screen -> collision disabled " should have worked! and it only includes sprites not on screen.. There might be some events that conflicts with it or maybe you did not include this event below.

    If Sprite is on screen then

    --> Set collision enabled

  • Why set the collisions disabled?

    The way you explain it the collisions happen because of the solid behaviour..

    If that is true, setting the solid behaviour disabled should do the trck..

    Also, if they are moving (without movement no collisions) you could just set the movement to true only when near enough..

  • hmmm, idea behind it to reduce amunt of colision checks, the sprites are stationary but there is another sprite that has bullet behaviour and is all over the layout

    Havent tried disableing solid behaviour, will try that...

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