This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by ansimuz


I am having trouble making 2 fixed entities collide in the y axis.

I made a block entity that is pushable. but when i push it over another instance of the same object it falls ignoring the other block and even the collision map. See animation.

/><br />
<br />
Funny thing is that for some reason it works at times and other times it does't i think i am doing it wrong, please advice.<br />
<br />
Simplified code (and shows the same issue)<br />
<br />
<pre class= ig.module( 'game.entities.moving-block-test' ) .requires( 'impact.entity' ) .defines(function(){ EntityMovingBlockTest = ig.Entity.extend({ size: {x: 16, y:16}, isBlocked: false, playerPosX: 0, maxVel: {x: 10, y:99}, otherBlocksArr: null, collides: ig.Entity.COLLIDES.FIXED, type: ig.Entity.TYPE.B, checkAgainst: ig.Entity.TYPE.BOTH, animSheet: new ig.AnimationSheet( 'media/blocks.png', 16, 16 ), init: function( x, y, settings ) { this.parent( x, y, settings ); // Add the animations this.addAnim( 'idle', 1, [0] ); }, receiveDamage: function(amount,from){ this.parent(0,this); }, update: function() { this.parent(); } }); });

1 decade ago by tunglxx226

How about you try changing the ig.Entity.COLLIDES.FIXED into ig.Entity.COLLIDES.A?

1 decade ago by giodif

I don't think that the blocks are ignoring anything. The collisions for fixed vs. fixed entities are undefined and it looks like you've still got the gravityFactor set to 1. The pull of gravity is probably creating a small jitter that ( sometimes ) pulls the box into the box below it. Then, the jitter also pushes through the static collision tiles. I've noticed from some of my tests that it doesn't take much to push an entity through the static tiles.

A few assumptions:

1. It looks like you want the block to stay put unless the player intentionally pushes.

2. You don't want the blocks set to ACTIVE because then when the player bumps into them, both the player and the block will move.

3. You need the blocks to be stackable and to be affected by gravity.

I think you can try a couple strategies:

1. Have the block's gravityFactor default to 0. If the player pushes it ( if it's vel.x is greater that 0 ) set the gravityFactor to 1. Then reset it to 0 whenever it detects it's first y collision. Remember to round off the block's position so that you don't get any tiny offsets in position. Log the position and you'll see what I mean.

I think this will work because you'll then have an object that 'sticks' in place. You'll stop any errant collisions and you'll have an object that is FIXED and won't move if bumped by the player or enemies.

2. Set the player's collide's property to LITE and the blocks to ACTIVE. I'm fairly certain that LITE vs. ACTIVE collisions only move the LITE entity. My thinking here is that ACTIVE vs. ACTIVE collisions are resolved and might not create the same type of weird jitter that FIXED vs. FIXED collisions seem to create. Or they might, hard to be certain.

I think the problem is that the bottom block is being sandwiched between an entity (dynamic collision) and a collision tile (static collision). So, the block on top is 'pushing' down and the static tile is 'pushing' up. The middle block jitters and everything goes shit-bonkers.

Just spitballing ideas here, but hopefully this will point you in the right direction. I'd log block vs. block collisions to see whats up. Definitely, see if you are getting jitters from gravity.

Best of luck.

1 decade ago by giodif

By the way, I love the artwork.

1 decade ago by ansimuz

I changed the collides to ACTIVE VS LITE as you mentioned in point #2 it works like a charm


1 decade ago by Ash_Blue

Thanks, this just saved me quite the headache.
Page 1 of 1
« first « previous next › last »