How do I check collision less regularly in this case?

Get help using Construct 2

Post » Mon Jul 13, 2015 10:16 am

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?
B
8
S
2
Posts: 59
Reputation: 686

Post » Mon Jul 13, 2015 2:12 pm

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.
B
17
S
7
Posts: 280
Reputation: 2,522

Post » Mon Jul 13, 2015 3:43 pm

RayKi wrote: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.
B
8
S
2
Posts: 59
Reputation: 686


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests