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 Hareesun

So, I'm trying to check if an entity is touching a wall (part of the collisionMap) and if so do something.

I've tried using handleMovementTrace but that only partially works. The player has to be walking against the wall for that to work.

Any help? :)

1 decade ago by TylerAppmobi

If you take apart the spike entity in the jump n run demo, there is a good example of how to detect the collision map. I'd paste code but I'm on my phone :) I will when I get home though

1 decade ago by Hareesun

Quote from TylerAppmobi
If you take apart the spike entity in the jump n run demo, there is a good example of how to detect the collision map. I'd paste code but I'm on my phone :) I will when I get home though


Awesome, had no idea. Thanks for that! :)

EDIT: Here's a slightly modified (so it works on all four walls) working snippet

if(ig.game.collisionMap.getTile(this.pos.x + this.size.x, this.pos.y + this.size.y) 
|| ig.game.collisionMap.getTile(this.pos.x - this.size.x, this.pos.y - this.size.y)) {
  // IF COLLIDING WITH A WALL DO THIS
} else {
  // IF NOT, DO THIS
}
Page 1 of 1
« first « previous next › last »