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

1 decade ago by stahlmanDesign

I have a game map with land, sky and water. Is it possible for an entity to detect the type of collision image without making the water an entity? Instead of just collision being tangible or intangible, can I detect when it is touching the water tiles to make the player behave like he's in water?

I know how to do this using trigger entities, but I have some complex water and it would take a lot of trigger entity boxes to cover it all.

If I could detect when I hit the water, then it could automatically invoke the swimming animation and affect gravity accordingly.

1 decade ago by stahlmanDesign

OK I read up on Static collision :
So if you want an entity to opt out of static collision, the easiest way to do this, is to overwrite the .handleMovemenTrace() method for this entity with an empty function. In this method, you can also check with which tile the entity collided and act accordingly (e.g. if you have tiles that are slippery).

If, for instance, you want to play a sound when your player entity hits the floor with a certain speed, you can overwrite .handleMovementTrace() and check for collision and speed.

So I understand the example for playing a sound if you hit the ground hard, but how could I use a different tile on the collision layer to represent water, and then detect that it is hitting water and not a wall?

Something like this (my "code" in UPPERCASE to show what I sort of imagine it might be like)

handleMovementTrace: function( res ) {
if( res.collision.TILE_TYPE_IS_WATER ) {

// Continue resolving the collision as normal

1 decade ago by Hareesun

// Pass through the 2nd tile on the collision sheet.
handleMovementTrace: function(res) {
  var waterTile = 2;
  if (res.tile.x == waterTile) {
    res.collision.x = false;
    res.pos.x = this.pos.x + this.vel.x * ig.system.tick;
  if (res.tile.y == waterTile) {
    res.collision.y = false;
    res.pos.y = this.pos.y + this.vel.y * ig.system.tick;

When laying your collisionMap in the Weltmeister use the 2nd tile along. The above code will allow the entity to pass right through that tile as if it wasn't there, but you can edit this to react as if in water, etc... :)

By 2nd tile I mean the blue one here:
/>			</div>
			<div class=

1 decade ago by stahlmanDesign

You understood exactly what I wanted to do.

I had to get rid of this part in the IF statements :

&& (this.vel.x < 0 || this.pos.x > res.pos.x)
&& (this.vel.y < 0 || this.pos.y > res.pos.y)

But other than that, it's just what I was looking for. Thank you

1 decade ago by Hareesun

Oh yeah, sorry about that got all my wires crossed. :|

Boom, edited it out of my original post.
Page 1 of 1
« first « previous next › last »