When to check for collision?

0 favourites
  • 4 posts
  • Hello everyone,

    I was trying to optimize the performance of my game and I was wondering if you could give me some advice on when to check collision. Should I only check for collision (Player | On collision with Enemy) when enemy is on screen? Or it doesn't change anything. I was thinking that maybe it was checking for collision with all objects in the whole layout and that this practice could help performance.

    Am I right or wrong? Do you have any advice about this?

    Thanks!

  • I wouldn't think it would impact the performance too much, even with a large amount of enemies in one layout, but that's one piece of coding that definitely wouldn't cause any problems if you tossed it in.

    Better to err on the side of caution, I say.

  • With the latest version of C2 you can check for collisions freely and the new collision cell optimisation system will ensure that performance is never hit too hard.

    Essentially, it automatically does what you're worried about, restricting the scope of the collision checks to cells (which are the size of the screen) so that processing power isn't wasted checking for collisions that could never happen.

    Read about it here.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yea, but don't forget, that any instances switch collision check back. Read that blog post more closely.

    To example: - > (event) if enemy is on screen

                         (sub event) if enemy collision with enemy - blah-blah-blah. - this is bad.

    You need : (event) every 0.09 seconds

                 (sub event) enemy is not on screen - > disable collision check. - das ist good )))

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