How do I check collision less regularly in this case?

0 favourites
  • 3 posts
From the Asset Store
The game will give you a dog that appeared and you must say if he appeared more, less or equal.
  • Hi there,

    I have an *Enemy* in my game that moves Left and Right with the default Platform behaviour, with an instance variable the toggles in the code.

    -> When var "LEFT" = 1

    -> Simulate control moving left

    -> When var "RIGHT" = 1

    -> Simulate control moving right

    I am assuming that these both run at 60 times a second as default. The behaviour of the enemy is that he should keep running LEFT until he hits a *Block* then he goes RIGHT. Here's where it gets intensive - there are usually about 50 - 200 blocks in the game at any one time, so if he's always checking collision with *Block* it generates "60*#ofBlocks" collision checks per second, per *Enemy*.

    Is there a better way of checking collision so that it doesn't swamp my game down whenever these enemies are put in?

    P.S. - *Enemy* is 128 pixels wide. Would checking his X - 64, X + 64 for an instance of block work better?

  • Are you checking the collision with all the blocks in the game?

    Usually I create a turning point for the enemy using a invisible block, so the turning will be triggered on collision instead of checking collision every tick.

    Hope it helps.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are you checking the collision with all the blocks in the game?

    Usually I create a turning point for the enemy using a invisible block, so the turning will be triggered on collision instead of checking collision every tick.

    Hope it helps.

    Hey! thanks for replying.

    The problem is that the enemy can end up anywhere on the map (he can fall through part of the world but must still keep moving). I too have used invisible blocks to do "left right" before, but these enemies must continue where-ever they go within the destructible blocks, and must be able to collide with any of them if it hits them.

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