Impact

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

1 decade ago by harryfeng

Hi,

So I have one player and multiple monster on the ground. I want those monster block the player but not monster won't block each other.

How can I set up collision type for this situation?

1 decade ago by dominic

Using the .collides property, give your player the ACTIVE and your monsters the PASSIVE collision modes.

1 decade ago by harryfeng

thanks, it work. and also you need to set

type: ig.Entity.TYPE.A, for both player and monster.

but now I have another problem. monster are not moving. when player hit those static monster, the player can push to move. I don't want them to push to move.

any suggestion?

I set this.vel.x = 0 for monster. but it still move a bit when the player push them.

1 decade ago by dominic

Well, then it gets a bit more complicated. Normally, if two entities collide, either both entities will be moved to resolve the collision (like in your case right now), or if one entity is strong or the other is weak, only the weak one will get moved.

So, you actually want the monters to be strong (i.e. FIXED), but this doesn&039;t work because they will then collide with each other. If you set your player to be _weak_ (i.e. #LITE) the collision between monsters and the player will be ignored, since PASSIVE doesn&039;t collide with #LITE.

There is however a way to still force this collision to happen. Do this in your player entity:
EntityPlayer = ig.Entity.extend({
	checkAgainst: ig.Entity.TYPE.A, // check against monsters
	collides: ig.Entity.COLLIDES.LITE, // set "weak" collision mode
	
	check: function( other ) {
		// 'other' should be a monster... check for it to be sure:
		if( other instanceof EntityMonster ) {
			
			// resolve collision between player (this) and monster (other)
			ig.Entity.solveCollision( this, other );
		}
	}
});

I hope this makes sense... and works - I didn't test it :)
Page 1 of 1
« first « previous next › last »