The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

In my player script I emit a signal when the mouse is pressed and a collision is detected with a RayCast2d collision point. This should remove the block that the RayCast2d being projected from the player collides with, but it seems to be inconsistent about what blocks it actually removes even some parts of the map it wont remove any blocks at all.
I didn't notice anything amiss when I output all the relevant variables to the console. I've been hitting my head on a wall trying to diagnose this for hours at this point any help is appreciated.

Here's the relevant code:

extends KinematicBody2D

signal hit(collision_point)

func mine():
    if mine_ray.is_colliding():
        var collision_point = mine_ray.get_collision_point()
        emit_signal("hit", collision_point)

func _physics_process(delta):

    if Input.is_action_pressed("ui_mine"):

And in the script for the tilemap I have:

extends TileMap

func _on_Player_hit(collision_point):
    var tile = world_to_map(collision_point)
    set_cell(tile.x, tile.y, -1)

Thanks for your input!

in Engine by (15 points)

1 Answer

0 votes

you can try visualizing the collision shape, there is an option under debug on the top bar

I just solved a similar issue, it is caused by the collision shapes of the tiles are colliding with each other and shift away

by (14 points)

Unfortunately thats not the issue here, I can see the ray intersecting with a tile and yet when I click it doesnt always remove the expected one.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.