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

Get help using Construct 2

Post » Wed Aug 12, 2015 2:11 pm

How do I find out which specific tile ID my sprite is colliding with?
Is there a way ?
B
12
S
3
Posts: 288
Reputation: 1,694

Post » Wed Aug 12, 2015 2:38 pm

Make a global variable "var".

Player on collision with collisionObject -> set "var" to collisionObject.uid (or collisionObject.iid if you need the IID instead)
B
10
S
4
G
2
Posts: 117
Reputation: 1,872

Post » Wed Aug 12, 2015 3:03 pm

Toddler wrote: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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Wed Aug 12, 2015 3:33 pm

nimos100 wrote:
Toddler wrote: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.
B
12
S
3
Posts: 288
Reputation: 1,694

Post » Wed Aug 12, 2015 7:18 pm

Toddler wrote:
nimos100 wrote:
Toddler wrote: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?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Thu Aug 13, 2015 12:16 am

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.
B
12
S
3
Posts: 288
Reputation: 1,694


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983, KTML5 and 5 guests