+1 vote

I'm working on a project and it's going super smoothly, but I ran into one problem I can't seem to solve without doing super tedious collision drawing.

The problem is that I made an auto tileset to put down thorny vines. I enabled and set the built-in collisions for the auto tilesets and put them on a "hurtingTile" collision layer. The only problem is that now I pretty much just have a new wall tileset that looks like thorns.

What I wish for is the tileset's collision to be the cause of a "HURT" state, but tilemaps don't have any built-in collision signals.

As a temporary workaround, I made an area2d node with a ton of separate collision shapes that work as static enemies that can hurt the player. This method is functional, but the only problem is that this is not very neat and fills up the tree with a ton of unoptimized nodes.

What I'm asking is if there is anything that I can use that would,

if colliding ----> Get Collision ----> if collision = Player ----> Player.state = HURT

all built into the built-in auto tilemap collisions.

Thank you :)

in Engine by (47 points)

if your character can only move to one position per tile, the center one
like this: https://gotm.io/henry-software/pixelleveltest/

then collision can be simplified a lot... instead of adding an area2d and collision shapes and doing a raycast in a direction you can simply get the tile in any space beside the character and check if it is a wall tile or a blocking tile or damage tile
but if you can can move anywhere on the tile then you need raycasts and physics i guess

your probably know this and are using physics for a reason but just fyi maybe

Why not give the tile map a group, call it "hurt" or something, and then when the player collides with something it can check the collider's group to see if it has that group. The tilemap won't be moving, so it's not like it needs to check collisions itself. You'll need more than one tilemap, I think, but that should be OK. If we're off base here, please give us some more details so we might be able to help.

That sounds pretty spot on. How would I go about giving the tilemap a "group"?

You can add a group to a node in the Node tab. It's a sub-tab next to Signals. See this tutorial in the docs for a screenshot and some more instructions.

Well it took a few hours of trial and error, but I finally got it to work :))))
Thank you for the help :))

this is pretty much what I used (I use moveandslide)

func _physics_process(delta):
    var slide_count = get_slide_count()
    if slide_count:
        var collision = get_slide_collision(slide_count - 1)
        var collider = collision.collider
        if collider.is_in_group("hurt"):
            queue_free()

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.