Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Jackson King |
I have this code which tracks if the player is hitting a specific tile from below.
Under my Player (KinematicBody2D) script:
for collision_id in get_slide_count():
var collision = get_slide_collision(collision_id)
if collision.collider is TileMap:
var normal = collision.normal
if normal == Vector2(0, 1):
var tile_pos = collision.collider.world_to_map(position)
tile_pos -= collision.normal
var tile = collision.collider.get_cellv(tile_pos)
var tile_name = collision.collider.tile_set.tile_get_name(tile)
if "SpecialBlock01" in tile_name:
if power > 0:
emit_signal("collided", collision)
else:
pass
Under my World (Node2D) script:
func _on_Player_collided(collision):
var tile_pos = collision.collider.world_to_map($Player.position)
tile_pos -= collision.normal
$TileMap.set_cellv(tile_pos, -1)
However, I’m experiencing a problem where my code works, but it there is a bit of a delay between when a character hits the block and when the block is removed. Is there a way to minimize this delay, or is the nature of what I’m trying to do not possible to be done in a faster manor.