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.
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,
collides: ig.Entity.COLLIDES.LITE,
check: function( other ) {
if( other instanceof EntityMonster ) {
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 »