0 Favourites

specific tile on tilemap - collision/overlapping

  • Hey,

    I want to do something like this :

    "playerSprite" is overlapping "tileMap : tile ID 0" > erase tile

    But I don't understand how to specify tile since overlapping event works on entire tile map.

  • This is an example from another thread, what you are looing for is condition (4), that's how you can check if something is overlapping a specific tile on a tilemap.

    (Be advise that the tilemap at row 0 for both X and Y is empty so its not an error that it seems like it should be tile 3,7, its just me that didn't put any tiles in that row, so the white area around the tiles are actually row 0)

    If you want the coordinate in X,Y you can just convert the TileX and TileY to that.

  • Thank you but what i'm looking for is a way to pick tiles by ID (as it can be seen on tile map bar).

    Unfortunaly there is no simple condition, but I guess it's possible since tile IDs exist... No?

  • The Tile ID is the tiles position in the tilemap. So you have to check for it like in my example.

    1. Which tile you want to check

    2. What type of tile is it

    In my example above I check the tile underneath the bullet and check if that is a tile type of 4, which are the ID you are talking about.

  • Thank you for help!

    It's actually too complicated for picking tile by ID for a non programmer like me.

    I guess one day there will be simple condition like :

    add new condition > on collision with another object > tileMap (indicate tile ID in text field below)... and that's it!

    Until this kind of improvement, I will use tile map only for decoration.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thank you for help!

    It's actually too complicated for picking tile by ID for a non programmer like me.

    I guess one day there will be simple condition like :

    add new condition > on collision with another object > tileMap (indicate tile ID in text field below)... and that's it!

    Until this kind of improvement, I will use tile map only for decoration.

    The tilemap is not really that hard to use once you understand the basics of how it is constructed.

    Image (1): Just using the basic tilemap in C2. You can look at a tilemap as being just a collection of images combined into 1 image. The reason to use a tilemap is because you can reuse a lot of graphic and reduce the performance hit from using a lot of sprites. So instead of adding lots of objects you simply add a tilemap and reuse the graphic over and over. There are some other benefits as well, but to keep it simple ill just focus on the basics.

    Image (2): Shows a single tile in the tilemap, which current size is set to 32 x 32 px, this is equal to adding a sprite and setting its width and height to 32px. But since the tilemap split the image into tiles, you need to tell C2 what size these tiles are, so it knows how many tiles the tilemap should contain.

    Image (3): Once the size of each tile have been set, C2 split the image into tiles and give each of them an ID, so its easy for you to see which graphic belongs to what tile. And it makes it possible for C2 to work with the tiles. This ID identify what image is related to a given tile. And can be compared to you making 2 sprites and calling one of them "Image_1" and the other "Image_2".

    Image (4): Guess this might be what confuse you a bit. But the tilemap object can be compared to adding a lot of sprites next to each other. But instead of you having to add all of them, you just add the tilemap object and C2 will then split it up for you in the tile sizes that you set in Image (2). The tilemap object, that being the one in the C2 viewport will be split into areas that match the size of the tile width and height.

    So a tilemap that is 320x320 px and have a tile width and height of 32 x 32 px will have 10 tiles in X and 10 tiles in Y. And each of these tiles will have an index so C2 know which tile is which. Looking at Image (4) you can see the tile coordinates, which always starts at 0,0 in the top left tile. This coordinate have nothing to do with the X,Y value in the normal coordinate system that C2 uses. So you can place the tilemap at X: 500 and Y: 500 in the viewport, but the top left tile in the tilemap will always be (0,0).

    Image (5): Shows a tile placed on the tilemap, this tile have the tile position of (2,1) and looking at the overview in image (3) you can see that the ID of the tile is 0.

    If this is makes sense to you, you can see that you can't work with a tile ID alone. Because it simply relates to what type of tile it is. You have to first tell C2 which tile coordinate you want to test.

    And you do that by using the condition "Compare tile at":

    To test it:

    So you just have to remember that Tile ID and Tile coordinate cant work without each other. The Tile ID is the tile graphic in the tilemap, and the tile coordinate is on the tilemap it self.

  • Thank you very much for this explaination.

    So, if I understand well, I have to specify coordination for all tiles wich have same ID?

    If I have 30 tiles "ID:3", I must create 30 conditions for each tiles if I want add an action "on collision/ is overlapping"?

    It's sounds crazy.....

  • Thank you very much for this explaination.

    So, if I understand well, I have to specify coordination for all tiles wich have same ID?

    If I have 30 tiles "ID:3", I must create 30 conditions for each tiles if I want add an action "on collision/ is overlapping"?

    It's sounds crazy.....

    No, the coordinates and IDs are automatically created by C2. For the coordinates as shown in image (4) these are the same no matter what tilemap you use. So top left corner will always be (0,0) regardless of your tiles being 32x32 px or 128x128px.

    The tilemap object it self use its own coordinate system. Might be easier to understand if you try to make a tilemap and set the tile width and height to 1 px. Then it works the same way as the normal C2 coordinate system (X,Y) that you use whenever you make an object and move it around, all objects then have a X,Y coordinate that tells you where on the layout they are placed.

    Its the same for the tilemap except it also have it owns coordinate system that it uses for placing tile correct in the tilemap.

    So you don't specify a coordinate for each tile, you check a certain coordinate to see if it contain a certain tile.

    If you have 30 tiles with a tile that have ID:3 you use a "For..loop" to go through each tile and check whether a tile have an ID:3 tile at that position.

  • When I talk about improvement, I mean that all you say would be handled by C2 in background process.

    The actual way to specify tile by ID is really useful in many case but also tedious for non programmer users.

    So, the "improvement" that I talking about is only ergonomics :

    if the user add condition > on collision with another object > tileMap (indicate tile ID in text field below)

    C2 should manage to write all the things that you explained to me in the code (comparison tile at, for...loop, etc).

    I'm glad to learn what you explain to me, but I think that kind of improvement should be coherent with the principle of "no coding" developpement software.

  • When I talk about improvement, I mean that all you say would be handled by C2 in background process.

    The actual way to specify tile by ID is really useful in many case but also tedious for non programmer users.

    So, the "improvement" that I talking about is only ergonomics :

    if the user add condition > on collision with another object > tileMap (indicate tile ID in text field below)

    C2 should manage to write all the things that you explained to me in the code (comparison tile at, for...loop, etc).

    I'm glad to learn what you explain to me, but I think that kind of improvement should be coherent with the principle of "no coding" developpement software.

    But what you want to do is like it is, you just want to use Tile ID first instead of coordinate. But regardless of which approach you use, you are going to have to check the tile coordinate anyway.

    Your approach:

    Object collide with tile on tilemap that have a certain ID

    Find coordinate

    C2 approach:

    Check if object is colliding with a given coordinate

    Check if its a certain ID

    But its not really coding as I see it, its math using a very basic coordinate system.

  • Your approach:

    Object collide with tile on tilemap that have a certain ID

    Find coordinate

    Why do I have to find coordinate?

    my approach is :

    Object collide with tile that have a certain ID on tilemap

    and that's all. I just want to interacte with tile that have a certain ID on tilemap if this tile is collided by an object, whatever coodrdinate.

  • >

    > Your approach:

    > Object collide with tile on tilemap that have a certain ID

    > Find coordinate

    >

    >

    >

    Why do I have to find coordinate?

    my approach is :

    Object collide with tile that have a certain ID on tilemap

    and that's all. I just want to interacte with tile that have a certain ID on tilemap if this tile is collided by an object, whatever coodrdinate.

    Yeah guess it could be done, if C2 made all the checks. So you are actually requesting a feature, more than asking for how to do it I guess?

  • So you are actually requesting a feature, more than asking for how to do it I guess?

    It's sounds like that, right?

    Anyway I thank you for all the time you spend to explain to me how tilemap works in standard programming. In terms of "learning curve", it's very useful to me!

  • I bump this thread because I need some tips, if you please :

    I need that all tiles overlapped by the sprite collision polygon are erased, not only those are overlapped by the origin point of the sprite.

    How could I do that?

  • Nobody knows how to do it? Is it impossible?

    I'm stuck :/

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