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 jspence3

I'm trying to get collsion detection to work when a entity 32x32 is on top another entity 32x32. I know impact handles collision before that so how can get collision to work where I can check whether they are on top of each other?

1 decade ago by dominic

I'm not sure I understand correctly.

Either you disable collision for those two entities to allow them to overlap and then use the check() method, or you use the collideWith() method to do something on collision.

You can't have them overlap and collide - at least not in this universe :)

1 decade ago by jspence3

I have a top down game where an entity walks over other entities then actions happen. The movement is all grid based so when an entity walks over another entity I need to be able to do some action, but i need to know whether that entity is directly on top off the other entity in order to keep the grid movement accurate so the entity doesn't get off his path. I still need collision to work on the boundaries of the grid and also on unwalkable tiles. What would be the best solution for this problem?

1 decade ago by quidmonkey

If you know which Entities will interact with the grid-Entity (i.e. the Player), you could make your grid-Entity like this:

checkAgainst: ig.Entity.TYPE.NONE,
collides: ig.Entity.COLLIDES.NEVER,
type: ig.Entity.TYPE.NONE,

update: function(){
	this.parent();
	if( this.touches( ig.game.player ) ){
		//do something
	}
}

This will remove the grid-Entity from Impact's collision detection and manually check against the Player for a collision.

1 decade ago by jspence3

I must be doing it wrong because it's throwing an error on "ig.game.player" which i replaced with my own entity. Will .touches() work when all collision is turned off?

1 decade ago by quidmonkey

ig.game.player is a global reference to EntityPlayer. Grab the EntityPlayer explicity using .getEntitiesByType():

var player = ig.game.getEntitiesByType( EntityPlayer )[0];
if( this.touches( player ){
    //do something
}

1 decade ago by jspence3

If i have a list of entities that can touch my gridEntity then it would return as a list and I'd have to loop through the list and see if it's touching?

1 decade ago by quidmonkey

Yes. Let's say you have an Enemy entity:
var enemies = ig.game.getEntitiesByType( EntityEnemy );
for( var i = 0; i < enemies.length; i++ ){
    if( this.touches( enemies[i] ){
        //do something
    }
}
Page 1 of 1
« first « previous next › last »