How do I know which tile is being hit on collision

Get help using Construct 2

Post » Sun Jan 25, 2015 1:21 am

@ruskul, so, no chances to make the same thing with tiles? I am afraid my game will be too heavy... or limited. I want to spread those boxes everywhere.
B
8
S
2
Posts: 48
Reputation: 646

Post » Sun Jan 25, 2015 5:22 am

Hey... pretty much when @R0J0hound shows up, the magic happens.

I'm stuck in an 8 bit world though, with some of the projects I'm working on.
B
74
S
19
G
9
Posts: 377
Reputation: 9,258

Post » Sun Jan 25, 2015 8:41 pm

@R0J0hound, I replaced the sprite 2, which overlaps a tile, with a bullet. While bullet is colliding with a tile, the effect of overlapping does not appear. What was wrong?

Also, I am thinking about an interaction of 2 tilemaps on one layout. One tilemap is solid, the other one is unsolid. When I shoot at the tile of solid tilemap, this tile would be replaced with a tile of unsolid tilemap.
When I shoot at the tile of unsolid tilemap, this tile would be replaced with a tile of solid tilemap.

Is this interaction of 2 tilemaps possible in C2?

Thanks
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 48
Reputation: 646

Post » Mon Jan 26, 2015 12:01 am

@heliogame the use of 2 tilemaps is a good idea and is common practice. Really, anytime you have tilemaps and need some to be solid and others not, this is fine.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,173

Post » Tue Jan 27, 2015 5:57 am

heliogame wrote:R0J0hound, I replaced the sprite 2, which overlaps a tile, with a bullet. While bullet is colliding with a tile, the effect of overlapping does not appear. What was wrong?

It looks fine here. Slow the bullet if you want to see it longer.
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Tue Jan 27, 2015 7:20 pm

@R0J0hound, I slowed the bullet down, but collision does not appear. No visual change.

I also added an unsolid tilemap2 to the list.

When a bullet is collided with a tilemap, we should see the following:

1) The tile of tilemap is erased
2) and is replaced with a tile of unsolid tilemap2 ( I used "set a tile" trick, not sure if it is right).
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 48
Reputation: 646

Post » Wed Feb 25, 2015 1:45 pm

I have a similar problem here : http://canapin.com/construct/tolilo/09/
Left click to shoot (X if you have a plugged in gamepad).

The bullet is supposed to bounce of the green tiles, but sometimes it targets the next tile.

Plus, the bullet and the tilemap having a physic behavior, sometimes the bullet bounces of a tile but the event "bullet on collision with tile" is not triggered, that's why it sometimes bounces on purple tiles even if it shouldn't.

targettiles.png

(event 2 tests if it is a green tile)

What should I do ?
You do not have the required permissions to view the files attached to this post.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Feb 25, 2015 5:16 pm

@heliogame
The actions you're using to erase/set a tile are using
Tilemap.TileToPositionX(loopindex("tileX"))
but the actions are asking for tile column and row not layout x and y. So if you change it to:
loopindex("tileX")
it works.
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Wed Feb 25, 2015 5:32 pm

@Coin-coin le Canapin
map.tileAt() is just getting the tile the projectile's center is currently on, which will almost always be -1 or empty because when it collides with the tilemap only it's edge is touching a tile.

"on collision" may not be triggered because the physics already resolved the collision and it is no longer overlapping. You'd have to test this to be sure, since I thought that the physics behavior would trigger it directly.
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Wed Feb 25, 2015 6:26 pm

How dumb I am.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], RIDETHEPIG and 9 guests