Find out which specific tile ID my sprite is colliding with?

0 favourites
  • 6 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • How do I find out which specific tile ID my sprite is colliding with?

    Is there a way ?

  • Make a global variable "var".

    Player on collision with collisionObject -> set "var" to collisionObject.uid (or collisionObject.iid if you need the IID instead)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How do I find out which specific tile ID my sprite is colliding with?

    Is there a way ?

    You need to convert the sprite X,Y position to a tilemap position using the tilemap PositionToTile(X,Y) after that you can see if this position match the Tile ID where the collision occurs.

  • > How do I find out which specific tile ID my sprite is colliding with?

    > Is there a way ?

    >

    You need to convert the sprite X,Y position to a tilemap position using the tilemap PositionToTile(X,Y) after that you can see if this position match the Tile ID where the collision occurs.

    I was afraid of this.

    Guess I will avoid tilemap in the future now, this is unacceptable.

    Why can't one just have On Collision->Tilemap.collided_tile_id==xx

    Still, thank you very much nimos100.

  • >

    > > How do I find out which specific tile ID my sprite is colliding with?

    > > Is there a way ?

    > >

    > You need to convert the sprite X,Y position to a tilemap position using the tilemap PositionToTile(X,Y) after that you can see if this position match the Tile ID where the collision occurs.

    >

    I was afraid of this.

    Guess I will avoid tilemap in the future now, this is unacceptable.

    Why can't one just have On Collision->Tilemap.collided_tile_id==xx

    Still, thank you very much nimos100.

    Sure no problem, but don't get why you would avoid it cause of that, its one line of code where you put in the X,Y position and you get a Tilemap position?

  • Well, because I don't really know the exact X,Y position of the tile map, the registration point of my character is not on his feet, and even if it is, due to the platform behavior, it is not really overlapping the tile so...

    The point is, if it is on the feet, MAYBE I could find out the X position by doing a simple Y+1 to find out, but because the registration point of my character is not on the feet, I can kiss that option good bye, especially when my character is bigger than a single tile, then God knows if it is the tile on the left, middle or right.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)