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

9 years ago by drhayes

Y'know that trope where as you enter a room in a MetroidVania a pile of rocks falls behind you? Maybe four identical sections fall on top of each other, and the player can do nothing to move them.

My first attempt was to make the rock fall entity COLLIDES.FIXED. That worked for one stack on the map but (weirdly) not another. After a second or two, the second stack of rocks starting to shimmy through the floor. It's this problem all over again. I can't set their gravityFactor to 0 'cuz I want them to fall and bounce when first appearing. I could set it to 0 after they collide but that doesn't stop them from having a teensy bit of vel.y after a fall/bounce that keeps them intersecting.

Essentially, the two FIXED entities trade on who the weak entity is. The weak entity keeps getting shoved around. Occasionally, that weak entity is the lower rock fall in which case it might get shoved through the floor and voila! But a terrible kind of voila.

So, okay, I get it I get it, FIXED vs. FIXED entity collisions are no worky, it says so right in the code.

My next thought was to simulate the whole thing and modify the CollisionMap manually. Instead of entities, it just starts drawing images where the rock falls should be, watches their positions, makes them look bouncy, and sets collision tile 1 in the tile positions where the rock fall is happening.

I haven't done that yet because that means the rock fall must align on the tile boundaries of my map, which is kinda stinky. I could modify the collision tile definitions to make "half tiles" and "quarter tiles" that work vertically, I guess? But I'd miss the entity-vs-entity accuracy; I'd still be aligning on tile boundaries, just smaller ones.

So before I do all this: anyone got this working using entities?

EDIT: I no speak English good.

9 years ago by Joncom

Sounds kind of "hackish", but you say you already got one stack to work, just not the other. Perhaps look at what's happening in the scenario that works... Are the update calls for those entities taking place in a particular order? And if the order of the update calls can accomplish your goal, then it would be a simple case of sorting the entities (via zIndex or something) based on their y-position.

Edit: I too no speak English good.

9 years ago by Krisjet

The collision implementation in Impact just isn't robust enough for this kind of stuff. Whenever you have more than one entity colliding with another one, or fixed entities that collide with each other, you're gonna run into problems. I think your hackish version has promise, just fake it, I'm sure that's how they do it in Castlevania too :)

9 years ago by drhayes

It turns out the first stack has problems, too; they just take longer to show up.

@Joncom: That's what I kept looking for! The entities are instantiated in drop order via an EventChain, so the ordering is the same for both stacks. The tile alignment is the same (the rock fall spans three horizontal tiles in both cases). The heights and number of rock fall entities is the same. The only real difference I could see is the x coordinate between the two stacks. I give up. / =

@Krisjet: If I set them all ACTIVE it works but then the player can push them around. Might be nice to add a concept of mass/relative mass to entities, maybe? Instead of two non-weak entities that split the separation equally, they split it proportionately.

Here's how it is now for x:

  var v2 = (left.vel.x - right.vel.x)/2;
  left.vel.x = -v2;
  right.vel.x = v2;

Here's how it could be?

  var relMassRatio1 = 1 - (m1 / (m1 + m2));
  var relMassRatio2 = 1 - (m2 / (m1 + m2));
  if (m1 === Infinity) {
    relMassRatio1 = 0;
    relMassRatio2 = 1;
  } else if (m2 === Infinity) {
    relMassRatio1 = 1;
    relMassRatio2 = 0;
  // Separate.
  pos1 += Math.ceil(scalar * extent * relMassRatio1);
  pos2 -= Math.ceil(scalar * extent * relMassRatio2);

I took a crack at the tilemap version last night and got it working. It's not animating right now and it doesn't straddle correctly... but half tiles absolutely do work, and modifying the map worked just great.

I'll probably go with that.

9 years ago by Joncom

I wonder if you could somehow overload the checkPairs function such that, if one entity is the player, and the other is a rock, then temporarily set the player collides property to something like LITE. And switch it back to the default immediately after. This way you could have your rocks be ACTIVE, which you say somewhat works...


9 years ago by stillen

Couldn't you have the rocks fall with no collision at all. When they are finished falling, change the collision tiles behind them? That way you don't have to worry about entities colliding with each other and the normal collision map of the level would handle preventing the player from walking past or through the rocks?

9 years ago by drhayes

@Joncom: Thought about it, but I hate having to do that kind of special-casing. Especially since I'm going to re-use this rockfall thing and it's liable to get hit by all kinds of entities in the future, not just the player.

I could set the other entity to LITE no matter what unless the other entity is the rock fall entity, I guess? That feels even weirder, though. But I like that idea and had to chew it over for a couple of hours. Thanks!

@stillen: That's basically what I'm gonna do, yeah. Instead of "no collision at all" I'm just going to draw the image in place according to the entity's pos and set the collision map tile directly. That also neatly prevents the player from getting in the way and getting killed in a really cheap way.

9 years ago by drhayes

Got it working. ( =

I decided at the last minute that a column rising up out of the earth worked better, in this instance, than something falling and bouncing from the ceiling. Came out pretty good, if I do say so myself.

I didn't show it in the movie but the map's collision is set there, too.

9 years ago by stillen

The effect looks pretty cool.

9 years ago by Krisjet

The effect looks cool, as well as the game! Looking forward to playing it!

9 years ago by drhayes

Thanks! Y'all will be the first to know when it's done... in like two years. ( =
Page 1 of 1
« first « previous next › last »