Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phantom tilemap collisions breaking game #43306

Closed
Tracked by #45334
chucklepie opened this issue Nov 4, 2020 · 3 comments · Fixed by #51327
Closed
Tracked by #45334

Phantom tilemap collisions breaking game #43306

chucklepie opened this issue Nov 4, 2020 · 3 comments · Fixed by #51327

Comments

@chucklepie
Copy link

chucklepie commented Nov 4, 2020

Godot version:
3.2.2

OS/device including version:
Linux

Issue description:
In this picture a character has seemingly collided with the green foliage according to code:
image

When I look in code (below) I get the ID of 124, which is the green foliage, pretty standard code I believe to get tile id of a collision:

	var collision = move_and_collide(velocity * delta * Globals.bullet_time)
	if collision:
		if collision.collider is TileMap:
			var tile_pos = collision.collider.world_to_map(position)
			tile_pos -= collision.normal
			var tile_id = collision.collider.get_cellv(tile_pos)
			bounce=!collision.collider.tile_set.tile_get_shape_one_way (tile_id,0) 

tile_id returns 124. However, if you look at tile 124 in my screenshot below, which is the green foliage (4,3 in from the right) you will see there is not even a collision box and there is no data in the pane associated, yet Godot has raised a collision with it:
image

However, this character is moving slowly downwards so why is the collision only happening at the bottom of the foliage and not the top? Seems to me that the actual collision is possibly the tile below it (which does have a collision box). But as per my code I don't believe I've done anything wrong as this sequence of code to get the tile ID that collides and it works all the time elsewhere in my code. This, I believe, is the only code I know that can get the tile id from a collision (why a tilemap method is not provided, I don't really know...) and works. And it does work for 99% of the time...

My only conclusion is there is something wrong with the collider data/normal on a pixel boundary or something?

Steps to reproduce:
This happens randomly, I don't know how to create a simple project other than my git available project.

Minimal reproduction project:

@Calinou Calinou changed the title Phanton tilemap collisions breaking game Phantom tilemap collisions breaking game Nov 4, 2020
@Calinou
Copy link
Member

Calinou commented Nov 4, 2020

This happens randomly, I don't know how to create a simple project other than my git available project.

Unfortunately, we need a minimal reproduction project to be able to do anything here.

@chucklepie
Copy link
Author

chucklepie commented Nov 4, 2020

I'll try. But can you confirm that my code is the only way to get a tile id from a collision and the code is as it should? I can always point you in the direction of my git repo and while it's large it's literally a case of one tilemap and one scene code...

I just figured this is a problem for others or is known but not in an issue yet. It's like at the same time I keep getting random
scene/resources/tile_set.cpp:480 - Condition "!tile_map.has(p_id)" is true. Returned: SINGLE_TILE

errors in my tilemap and there are half a dozen similar faults associated with it and no obvious solution coming out of it, and I'm thinking they're possibly linked to internal bad IDs being used...

@akien-mga
Copy link
Member

Fixed by #51327.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants